微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Azure应用服务上运行的WCF服务的SSL设置问题

如何解决在Azure应用服务上运行的WCF服务的SSL设置问题

我目前正在开发一种wcf Web服务(.NET 4.7.2),该服务接受来自不同来源的肥皂消息。其中一种来源要求我们使用自定义授权机构(CA)创建一个由证书保护的端点。

为此,我创建了一个新的.svc文件,该文件使用以下绑定进行初始化并导入证书。可在azure网络应用程序中访问此证书:

public static void Configure(ServiceConfiguration config)
        {
            // Enable "Add Service Reference" support
            config.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpsGetEnabled = true,HttpGetEnabled = false }); //mex
            //setup support for certficate security
            var binding = new WSHttpBinding
            {
                Name = "CertificateBinding",ReaderQuotas = { MaxArrayLength = int.MaxValue },MaxReceivedMessageSize = int.MaxValue,Security = new WSHttpSecurity
                {
                    Mode = SecurityMode.Transport,Transport = new HttpTransportSecurity
                    {
                        ClientCredentialType = HttpClientCredentialType.Certificate
                    },},};

            config.EnableProtocol(binding);

            config.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser,StoreName.My,X509FindType.FindByThumbprint,"Thumbprint inserted here");

            config.Description.Behaviors.Add(new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true });
        }

要为此端点启用证书身份验证,我将以下内容添加到web.config;

 <location path="IntegrationWebService_CertificateSecurity.svc">
    <system.webServer>
    <httpErrors errorMode="Detailed"></httpErrors>
      <security>
        <access sslFlags="Ssl,SslNegotiateCert,SslRequireCert" />
      </security>
    </system.webServer>
 </location>

我对此进行了测试,并且在本地都可以正常运行,但是在部署到azure Web应用程序时显示500错误。我似乎无法弄清楚这500个错误的原因。其他.svc文件保持正常运行。

我尝试过的;

  • 添加ELMAH;没有异常被记录。

  • SslSettings的多种配置,尽管仅添加“ SslRequireCert”将错误更改为“服务'SslRequireCert'的SSL设置与IIS'无'的SSL设置不匹配”,但没有任何效果。我停止说这件事,因为据我所知需要SslNegotiateCert部分。

  • 尝试无济于事,添加了applicationHost.xdt文件,该文件将overrideModeDefault转换为允许这样的覆盖:

      <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
        <configSections>
          <sectionGroup name="system.webServer" xdt:Locator="Match(name)">
            <sectionGroup name="security" xdt:Locator="Match(name)">
              <section name="access" overrideModeDefault="Allow" xdt:Locator="Match(name)" xdt:Transform="SetAttributes(overrideModeDefault)" />
            </sectionGroup>
          </sectionGroup>
        </configSections>
      </configuration>
    

是不是Azure不允许在SslFlags中使用自定义值?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。