Azure应用程序服务上运行的WCF服务的SSL设置有问题
我目前正在开发一个wcf Web服务(.NET 4.7.2),它接受来自不同来源的soap消息。其中一个源要求我们使用自定义授权(CA)创建一个由证书保护的端点 为此,我创建了一个新的.svc文件,该文件使用以下绑定进行初始化并导入证书。此证书可在azure web应用程序中访问:Azure应用程序服务上运行的WCF服务的SSL设置有问题,azure,azure-web-app-service,wcf-security,Azure,Azure Web App Service,Wcf Security,我目前正在开发一个wcf Web服务(.NET 4.7.2),它接受来自不同来源的soap消息。其中一个源要求我们使用自定义授权(CA)创建一个由证书保护的端点 为此,我创建了一个新的.svc文件,该文件使用以下绑定进行初始化并导入证书。此证书可在azure web应用程序中访问: public static void Configure(ServiceConfiguration config) { // Enable "Add Service
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错误。我似乎无法找出这个错误的原因。其他.svc文件保持正常工作
我尝试过的
- 添加ELMAH;未记录任何异常
- SslSettings有多个配置,没有一个有效,但仅添加“SslRequireCert”会将错误更改为“服务“SslRequireCert”的SSL设置与IIS“none”的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中使用自定义值吗?我想知道这在AppServices中是否可能,因为TLS终止发生在应用程序本身之外。该应用程序仅获得HTTP连接。但是,您可以在app service本身@silent上配置mutual-TLS-auth,然后我将必须创建一个全新的web应用程序来启用证书身份验证,因为并非所有端点都应该使用此方法进行保护。但是,我可以添加证书排除路径,这是一个解决办法吗?我想知道这在AppServices中是否可能,因为TLS终止发生在应用程序本身之外。该应用程序仅获得HTTP连接。但是,您可以在app service本身@silent上配置mutual-TLS-auth,然后我将必须创建一个全新的web应用程序来启用证书身份验证,因为并非所有端点都应该使用此方法进行保护。但是,我可以添加证书排除路径,这是一种解决方法吗?