本文将为您提供关于该请求已中止:无法创建SSL/TLS安全通道的详细介绍,我们还将为您解释无法请求shsh的相关知识,同时,我们还将为您提供关于asp.net–“请求已中止:无法在Braintree中
本文将为您提供关于该请求已中止:无法创建SSL / TLS安全通道的详细介绍,我们还将为您解释无法请求shsh的相关知识,同时,我们还将为您提供关于asp.net – “请求已中止:无法在Braintree中创建SSL / TLS安全通道”错误、asp.net-mvc – 请求已中止:无法创建SSL / TLS安全通道.System.Net.WebException、ASP.NET和底层连接已关闭:无法为SSL / TLS安全通道建立信任关系、Azure DevOps Powershell脚本无法创建SSL / TLS安全通道的实用信息。
本文目录一览:- 该请求已中止:无法创建SSL / TLS安全通道(无法请求shsh)
- asp.net – “请求已中止:无法在Braintree中创建SSL / TLS安全通道”错误
- asp.net-mvc – 请求已中止:无法创建SSL / TLS安全通道.System.Net.WebException
- ASP.NET和底层连接已关闭:无法为SSL / TLS安全通道建立信任关系
- Azure DevOps Powershell脚本无法创建SSL / TLS安全通道
该请求已中止:无法创建SSL / TLS安全通道(无法请求shsh)
WebRequest
由于此错误消息,我们无法使用连接到HTTPS服务器:
The request was aborted: Could not create SSL/TLS secure channel.
我们知道服务器在使用的路径中没有有效的HTTPS证书,但是为了绕过此问题,我们使用了从另一StackOverflow帖子中获取的以下代码:
private void Somewhere() { ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(AlwaysGoodCertificate);}private static bool AlwaysGoodCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors) { return true;}
问题是服务器永远不会验证证书,并且会因上述错误而失败。有谁知道我该怎么办?
我应该提到,一个同事和我几周前进行了测试,并且与我上面写的类似,它运行良好。我们发现的唯一“主要区别”是我使用的是Windows
7,而他使用的是Windows XP。这会改变吗?
答案1
小编典典我终于找到了答案(我没有注明出处,但来自搜索);
当代码在Windows XP中运行时,在Windows 7中,必须在开头添加以下代码:
// using System.Net;ServicePointManager.Expect100Continue = true;ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;// Use SecurityProtocolType.Ssl3 if needed for compatibility reasons
现在,它可以完美运行。
附录
如罗宾·法文(Robin
French)所述;如果您在配置PayPal时遇到此问题,请注意,它们将从2018年12月3日开始不支持SSL3。您需要使用TLS。这是关于此的贝宝页面。
asp.net – “请求已中止:无法在Braintree中创建SSL / TLS安全通道”错误
var clientToken = gateway.ClientToken.generate();
我使用的是“Braintree-2.33.0.dll”,我的目标.net版本是4.5.1.
我启用了TLS 1.2.
它在三天前工作得很好.但突然开始显示错误.许多人遇到了同样的错误,大多数人都改变了SecurityProtocol.我没有找到任何方法来改变braintree.有没有办法改变
ServicePointManager.SecurityProtocol
对于braintree?或者我遗失或需要做的其他事情?
提前致谢.
解决方法
您需要将您正在使用的.NET Braintree SDK更新为至少version 3.1.0,这是支持TLS 1.2的最低版本.一旦完成,您可以使用步骤here验证您的设置.
December 13,2016,Braintree将沙箱转换为仅接受使用TLS 1.2发出的请求. 2017年6月30日之后,Braintree将不再正式支持TLS 1.2以下生产环境中的任何请求.
asp.net-mvc – 请求已中止:无法创建SSL / TLS安全通道.System.Net.WebException
The request was aborted: Could not create SSL/TLS secure channel.
我也使用Paypal的SandBox帐户进行测试.
它从这一行抛出错误:
var sw = new StreamWriter(req.GetRequestStream()
这是下面的代码:
var req = (HttpWebRequest)WebRequest.Create(GetPaypalUrl()); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ProtocolVersion = HttpVersion.Version10; string formContent = string.Format("cmd=_notify-synch&at={0}&tx={1}",_paypalStandardPaymentSettings.PdtToken,tx); req.ContentLength = formContent.Length; using (var sw = new StreamWriter(req.GetRequestStream(),Encoding.ASCII)) sw.Write(formContent);
解决方法
我相信PayPal在2016年1月19日更新了他们的终端,以使用TSL 1.2和HTTP 1.1.
要解决此问题,对于.NET 4.5及更高版本,在调用WebRequest.Create()之前添加以下代码行.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ASP.NET和底层连接已关闭:无法为SSL / TLS安全通道建立信任关系
禁用验证的选项不是一个选项.
这是代码
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://xxxxxxx/gateway.aspx"); string post = "abcdef"; req.ContentType = "application/x-www-form-urlencoded"; req.Method = "POST"; req.ContentLength = post.Length; var cert = System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile(@"c:\temp\root.cer"); req.ClientCertificates.Add(cert); StreamWriter stOut = new StreamWriter(req.GetRequestStream(),System.Text.Encoding.ASCII); stOut.Write(post.ToString()); stOut.Close(); HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
这是System.Net和System.Net套接字的系统日志.
System.Net信息:0:[5928] SecureChannel#8106798 – 无法将证书链构建到受信任的根颁发机构.
System.Net信息:0:[5928] SecureChannel#8106798 – 远程证书被用户验证为无效.
System.Net.sockets详细:0:[5928]套接字#7486778 :: dispose()
System.Net错误:0:[5928] HttpWebRequest中的异常#51319244 :: – 底层连接已关闭:无法为SSL / TLS安全通道建立信任关系.
System.Net错误:0:[5928] HttpWebRequest中的异常#51319244 :: EndGetRequestStream – 底层连接已关闭:无法为SSL / TLS安全通道建立信任关系.
更多信息
如果我使用此代码(来自CodeGuru)
public static bool ValidateServerCertificate(object sender,X509Certificate certificate,X509Chain chain,SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors) { return false; } else if (sslPolicyErrors == SslPolicyErrors.RemoteCertificateNameMismatch) { System.Security.Policy.Zone z = System.Security.Policy.Zone.CreateFromUrl (((HttpWebRequest)sender).RequestUri.ToString()); if (z.SecurityZone == System.Security.SecurityZone.Intranet || z.SecurityZone == System.Security.SecurityZone.MyComputer) { return true; } return false; } return true; }
我最终得到错误:
Remote Certificate Chain Error
解决方法
ServicePointManager.ServerCertificateValidationCallback += (sender,certificate,chain,sslPolicyErrors) => true;
它基本上允许服务器与其证书不匹配.
资源:
http://www.ben-morris.com/asp-net-web-services-and-ssl-certificates-establishing-a-trust-relationship
注意:建议不要将此解决方法用于生产
Azure DevOps Powershell脚本无法创建SSL / TLS安全通道
几乎没有可行的解决方法。
-
解决方法1
- 使用Azure Powershell任务版本5
- 选择“ Azure资源管理器连接”
- 将ASM Module commands更改为Az commands
-
解决方法2
- 使用Azure Powershell任务版本3
- 经典连接
- 将Azure Powershell版本降级到4.2.1
-
解决方法3(对于私人代理)
- 在CurrentUser \ My商店中创建一个自签名证书。您可以在这里找到有关创建自签名证书的详细信息:https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-certs-create
- 将证书的公共密钥导出为DER编码的CER文件(您可以为此使用mmc或任何其他证书工具)
- 通过以下门户网站将.Cer文件作为管理证书上传:https://docs.microsoft.com/en-us/previous-versions/azure/azure-api-management-certs
- 使用Set-AzureSubscription进行身份验证:
PS C:\> Clear-AzureProfile PS C:\> $cert = Get-Item Cert:\CurrentUser\My\ PS C:\ > Set-AzureSubscription -SubscriptionName "" -SubscriptionId -Certificate $cert PS C:\> Select-AzureSubscription -SubscriptionId
-
解决方法4
-
将以下脚本添加到每个Azure Powershell任务
$p = (Get-Variable Endpoint -ValueOnly).Auth.Parameters.certificate $bytes = [convert]::FromBase64String($p) [IO.File]::WriteAllBytes("C:\cert.pfx",$bytes) Import-PfxCertificate -FilePath C:\cert.pfx -CertStoreLocation cert:\CurrentUser\My . . actual script . . #remove certificate from store $thumb = (Get-PfxData -FilePath "C:\cert.pfx").EndEntityCertificates.Thumbprint Remove-Item -Path cert:\CurrentUser\My\$thumb -recurse -Force
-
我们有同样的问题。它仅出现在windows-2019
个代理上,而不出现在vs2017-win2016
上。
因此,您可以通过更改代理类型来修复它,但是更好的解决方法是使用特定的Powershell版本5.1.1
而不是latest
。看来latest
最近增加到5.3.0
导致此错误。
我遇到了同样的问题,并尝试了所有这些问题,对我来说,只有在我在Initialize-Azure部分之后添加此代码后,它才起作用:“ Set-AzureSubscription -SubscriptionId [我的订阅ID] -CurrentStorageAccountName [存储名称]”
,这似乎是Microsoft构建代理的问题,但是在每个Azure Powershell任务的开头添加以下代码似乎已经为我们解决了这一问题,直到他们弄清楚为止。
$pcert = (Get-Variable Endpoint -ValueOnly).Auth.Parameters.certificate
$bytes = [convert]::FromBase64String($pcert)
[IO.File]::WriteAllBytes("C:\cert.pfx",$bytes)
$null = Import-PfxCertificate -FilePath C:\cert.pfx -CertStoreLocation cert:\CurrentUser\My
,
此问题是由.NET September更新中引入的行为更改引起的。以下代码将通过环境变量还原密钥的隐式存储(以前的.Net 4.x行为):
with
cart_cte(ordernumber,ProductId,OrderDate,quantity,rn) as (
select *,row_number() over (partition by ordernumber order by OrderDate)
from ShopCart),prod_cte(ProductId,sum_quantity) as (
select ProductId,sum(quantity)
from cart_cte cc
join ShopCart sc on cc.ordernumber=sc.ordernumber
where cc.rn=1
and cc.orderdate < DATEADD(hour,-8,SYSDATETIMEOFFSET())
group by ProductId)
update p
set quantity=quantity+pc.sum_quantity
from Products p
join prod_cte pc on p.ProductId=pc.ProductId;
注意:然后,您将需要创建一个新的publishsettings文件,因为旧的证书和密钥不会被后续的导入覆盖。
,使用AzurePowerShell @ 3任务将Az Powershell版本降级到4.2.1。
,就我而言,我在本地Team Foundation Server 2017上的“运行嵌入式Azure Powershell”任务中的Get-AzureServiceRemoteDesktopExtension
命令中遇到了这个问题。
我尝试添加此处建议的行@ damien-caro ...
Set-Item env:\COMPLUS_CngImplicitPersistKeySet 1
...到我的脚本,但这只能解决单个发行版的问题。所有后续发行/部署均再次失败,并以Could not create SSL/TLS secure channel
结束。
只需将其作为变量添加到发行版定义中即可解决此问题。 (为进行测试,我已经成功地将相同的发行版连续三次部署到两个环境中。)
我在这里找到了此解决方案:https://github.com/Azure/azure-powershell/issues/13117#issuecomment-706665722
,就我而言,我不小心提到了 https 而不是 http。我的报表服务器是 http,没有证书,但它曾经在浏览器中重定向,即使我在我们的组织内部键入 https。但是 powershell 需要确切的 url。我使用的版本是 powershell@2,我调用了一个 powershell 脚本文件。
今天关于该请求已中止:无法创建SSL / TLS安全通道和无法请求shsh的介绍到此结束,谢谢您的阅读,有关asp.net – “请求已中止:无法在Braintree中创建SSL / TLS安全通道”错误、asp.net-mvc – 请求已中止:无法创建SSL / TLS安全通道.System.Net.WebException、ASP.NET和底层连接已关闭:无法为SSL / TLS安全通道建立信任关系、Azure DevOps Powershell脚本无法创建SSL / TLS安全通道等更多相关知识的信息可以在本站进行查询。
本文标签: