WCF服务无法在HTTPS上运行

时间:2019-01-14 03:34:46

标签: wcf ssl iis

我正在运行IIS 7.5,并且我的asp.net mvc网站具有SSL证书。我的服务是我网站的免费服务,因此我使用https://www.example.com访问该网站,并通过https://www.example.com/MyService/Service1.svc访问该服务。

我有适用于HTTP的代码,但是我一直在尝试将其迁移到HTTPS以及我在网上找到的任何示例:Microsoft,Stackoverflow,Youtube等。它们都以相同的方式进行操作,但是对于由于某些原因我无法运行我的代码。谁能帮帮我。

使用“添加服务引用”时的Visual Studio错误消息: “下载'https://www.example.com/MyService/Service1.svc?wsdl/ $ metadata'时出错。 该请求已中止:无法创建SSL / TLS安全通道。 元数据包含无法解析的引用:“ https://www.example.com/MyService/Service1.svc?wsdl”。 无法使用权​​限“ www.example.com”为SSL / TLS建立安全通道。 该请求已中止:无法创建SSL / TLS安全通道。 如果服务是在当前解决方案中定义的,请尝试构建解决方案并再次添加服务引用。”

在我的服务器上,如果我进入IIS管理器并单击我的服务,然后在* .443(https)上单击“浏览www.example.com”,则会得到目录列表,这是我在Web上打开的项目之一.config。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <!--Email Information-->

  </appSettings>
  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.7" />
    <httpRuntime targetFramework="4.7" />
  </system.web>
  <system.serviceModel>

    <bindings>
      <wsHttpBinding>
        <binding name="secureHttpBinding">  
            <security mode="Transport">  
                <transport clientCredentialType="None"/>  
            </security>  
        </binding>  
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="MyService.MyServiceOperations"  behaviorConfiguration="MyServiceBehavior">
        <host>
            <baseAddresses>
                <add baseAddress="https://www.example.com"/>
            </baseAddresses>
        </host>
        <endpoint address="basic1" binding="wsHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyService.IUserOperations" />
        <endpoint address="basic1" binding="wsHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyService.IPaymentOperations" />
        <endpoint address="basic1" binding="wsHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyService.ILocationOperations" />
        <endpoint address="basic1" binding="wsHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyService.IInfoOperations" />
        <endpoint address="basic1" binding="wsHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyService.IServiceLocationOperations" />
        <endpoint address="basic1" binding="wsHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyService.IHelperOperations" />
        <endpoint address="basic1" binding="wsHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyService.IReporting" />
        <endpoint address="basic1" binding="wsHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyService.ISubItems" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="jsonEndPoints">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
  </system.webServer>
  <connectionStrings>
    <!--DB Connection Strings Have been Removed-->
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v13.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
     <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.13.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
    </providers>
  </entityFramework>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.13.0" newVersion="8.0.13.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.6.1.0" newVersion="3.6.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.EntityFrameworkCore" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.4.0" newVersion="2.1.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Remotion.Linq" publicKeyToken="fee00910d6e5f53b" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.1.0" newVersion="2.1.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.1.0" newVersion="2.1.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.1" newVersion="4.0.3.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.1.0" newVersion="2.1.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Caching.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.2.0" newVersion="2.1.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Caching.Memory" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.2.0" newVersion="2.1.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.6.0" newVersion="2.1.6.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

------用仅能找到的错误代码进行更新-----

事件代码:3005 事件消息:发生未处理的异常。 活动时间:1/13/2019 10:56:55 PM 活动时间(UTC):1/14/2019 5:56:55 AM 事件ID:ccf077ec0a414d6bb71d178ba496cec1 事件顺序:2 事件发生:1 事件详细代码:0

申请信息:     应用程序域:/ LM / W3SVC / 2 / ROOT-17-131919190153815312     信任等级:完整     应用程序虚拟路径:/     应用程序路径:C:\ inetpub \ wwwroot {Path}     机器名称:WEB

过程信息:     进程ID:3848     进程名称:w3wp.exe     帐户名称:IIS APPPOOL \ ASP.NET v4.0

异常信息:     异常类型:HttpException     异常消息:提供的URI方案'https'无效;预期的“ http”。 参数名称:通过    在System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext上下文,HttpApplication应用)    在System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext上下文,MethodInfo []处理程序)处    在System.Web.HttpApplication.InitSpecial(HttpApplicationState状态,MethodInfo []处理程序,IntPtr appContext,HttpContext上下文)    在System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext上下文)    在System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)中

提供的URI方案“ https”无效;预期的“ http”。 参数名称:通过    在System.ServiceModel.Channels.TransportChannelFactory 1.ValidateScheme(Uri via) at System.ServiceModel.Channels.HttpChannelFactory 1.ValidateCreateChannelParameters(EndpointAddress remoteAddress,Uri通过)处    在System.ServiceModel.Channels.HttpChannelFactory 1.OnCreateChannelCore(EndpointAddress remoteAddress, Uri via) at System.ServiceModel.Channels.ChannelFactoryBase 1.InternalCreateChannel(EndpointAddress地址,Uri通过)处    在System.ServiceModel.Channels.ServiceChannelFactory.ServiceChannelFactoryOverRequest.CreateInnerChannelBinder(EndpointAddress to,Uri via)    在System.ServiceModel.Channels.ServiceChannelFactory.CreateServiceChannel(EndpointAddress地址,Uri通过)    在System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel(类型channelType,EndpointAddress地址,Uri通过)    在System.ServiceModel.ChannelFactory 1.CreateChannel(EndpointAddress address, Uri via) at System.ServiceModel.ClientBase 1.CreateChannel()    在System.ServiceModel.ClientBase 1.CreateChannelInternal() at System.ServiceModel.ClientBase 1.get_Channel()    在C:\ Users \ User \ Desktop {Path} \ Reference.cs:line 6107中的TruckIt.TruckItWebOps.LocationOperationsClient.GetStates(Int32 CountryId)    在MyService.MvcApplication.Application_Start()中的C:\ Users \ User \ Desktop {path} \ Global.asax.cs:line 41

请求信息:     要求网址:https://www.example.com:443/     请求路径:/     用户主机地址:192.168.1.1     用户:
    已验证:错误     身份验证类型:
    线程帐户名称:IIS APPPOOL \ ASP.NET v4.0

线程信息:     线程ID:43     线程帐户名称:IIS APPPOOL \ ASP.NET v4.0     正在冒充:错误     堆栈跟踪:位于System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext上下文,HttpApplication应用)    在System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext上下文,MethodInfo []处理程序)处    在System.Web.HttpApplication.InitSpecial(HttpApplicationState状态,MethodInfo []处理程序,IntPtr appContext,HttpContext上下文)    在System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext上下文)    在System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)中

自定义事件详细信息:

1 个答案:

答案 0 :(得分:0)

对于所有那些给我智力上的回应的人,谢谢。对于那些只是将您引向另一页的愚蠢人员,祝您好运!生活中充斥着平庸的人,我保证你不会走远。

至于答案: 因此,我的服务将通过Web浏览器(所有浏览器)做出响应。所以我知道这不是web.config问题。因此,我回过头来调查了最初的想法,即我遇到了TLS和SSL问题。

  1. 访问此网站 https://www.ssllabs.com/ssltest/analyze.html?d=casnet.casusa.com&latest

  2. 该网站将告诉您您可能遇到的问题。就我而言,我在服务器上运行的是TLS和SSL的极旧版本。

  3. 我使用以下方法更新了SSL: https://social.technet.microsoft.com/Forums/office/en-US/02241093-187d-41e4-a0fe-1cd19331a9a2/how-to-enable-ssl-v3-on-windows-2008?forum=winserversecurity

  4. 我使用以下方法更新了TLS 1.1和1.2: https://tecadmin.net/enable-tls-on-windows-server-and-iis/

  5. 然后,我不得不在注册表中的个人计算机上更新上述SSL和TLS,而没有插入“服务器”密钥,而是最终安装了“客户端”密钥。

更新这些安全协议后,我能够通过Visual Studio 2017(最新版本为1/14/2019)进行连接。再一次,我非常感谢那些尝试进行一些工作并给我答案的人。