SSIS SecurityNegotiationException:无法为 SSL/TLS 建立安全通道(无证书)
SSIS SecurityNegotiationException: could not establish secure channel for SSL/TLS (no certificate)
我正在通过 SSIS 与网络服务集成。我不断收到似乎是无法与证书通信的错误。
当我 运行 在控制台中使用完全相同的代码时,它工作正常。
该服务不需要证书,这是 SSIS 的东西吗?我是 SSIS 的新手,所以这可能是一个基本问题。
异常:
System.ServiceModel.Security.SecurityNegotiationException: Could not establish secure channel for SSL/TLS with authority 'myurl'. --->
System.Net.WebException:请求被中止:无法创建 SSL/TLS 安全通道
代码如下:
var wsBinding = new WSHttpBinding(SecurityMode.Transport);
wsBinding.Name = "wsHttpBinding_GlobalCredentials";
wsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
EndpointAddress endpointAddress = new EndpointAddress("https://myurl/myservice.svc/Soap12_NoAuth");
using (GlobalCredentialsClient globalCredentialsClient = new GlobalCredentialsClient(wsBinding, endpointAddress))
{
try
{
globalCredentialsClient.ChannelFactory.Credentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication();
globalCredentialsClient.ChannelFactory.Credentials.ServiceCertificate.SslCertificateAuthentication.CertificateValidationMode = X509CertificateValidationMode.None;
GlobalAccount checkCredentialsResult = globalCredentialsClient.CheckCredentials(username, password);
MessageBox.Show("Result: " + checkCredentialsResult.OrgID.ToString());
Dts.Variables["sOrgName"].Value = checkCredentialsResult.Created;
globalCredentialsClient.Close();
}
catch (CommunicationException ce)
{
MessageBox.Show("Comms exc " + ce.ToString());
globalCredentialsClient.Abort();
}
}
预感,可能是 TLS 版本不匹配。失败的应用程序是哪个 .NET?
您可以尝试在 API 调用之前设置 TLS 版本。
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
或
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11
我正在通过 SSIS 与网络服务集成。我不断收到似乎是无法与证书通信的错误。
当我 运行 在控制台中使用完全相同的代码时,它工作正常。
该服务不需要证书,这是 SSIS 的东西吗?我是 SSIS 的新手,所以这可能是一个基本问题。
异常:
System.ServiceModel.Security.SecurityNegotiationException: Could not establish secure channel for SSL/TLS with authority 'myurl'. --->
System.Net.WebException:请求被中止:无法创建 SSL/TLS 安全通道
代码如下:
var wsBinding = new WSHttpBinding(SecurityMode.Transport);
wsBinding.Name = "wsHttpBinding_GlobalCredentials";
wsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
EndpointAddress endpointAddress = new EndpointAddress("https://myurl/myservice.svc/Soap12_NoAuth");
using (GlobalCredentialsClient globalCredentialsClient = new GlobalCredentialsClient(wsBinding, endpointAddress))
{
try
{
globalCredentialsClient.ChannelFactory.Credentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication();
globalCredentialsClient.ChannelFactory.Credentials.ServiceCertificate.SslCertificateAuthentication.CertificateValidationMode = X509CertificateValidationMode.None;
GlobalAccount checkCredentialsResult = globalCredentialsClient.CheckCredentials(username, password);
MessageBox.Show("Result: " + checkCredentialsResult.OrgID.ToString());
Dts.Variables["sOrgName"].Value = checkCredentialsResult.Created;
globalCredentialsClient.Close();
}
catch (CommunicationException ce)
{
MessageBox.Show("Comms exc " + ce.ToString());
globalCredentialsClient.Abort();
}
}
预感,可能是 TLS 版本不匹配。失败的应用程序是哪个 .NET?
您可以尝试在 API 调用之前设置 TLS 版本。
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
或
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11