我们已经为应用程序配置了Octopus部署。成功部署后,我们将在松弛状态下发送有关部署状态的通知。
However this steps is failing since last few days but I am not able to find out root cause of it.
We are getting below error:
______________________________________________________________________________
Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.
+ Invoke-RestMethod -Method POST -Body ($payload | ConvertTo-Json - ...
Error
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException+ FullyQualifiedError IdWebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
The remote script failed with exit code 1
______________________________________________________________________________
We have verified tls version on server.
We have referred few articles from net to bypass ssl or tls validation.
Powershell Script we are using
_____________________________________________________________________________
[Net.ServicePointManager] :: SecurityProtocol = [Net.SecurityProtocolType] :: Tls12
Invoke-RestMethod -Method POST -Body($ payload | ConvertTo-Json -Depth 4)-Uri $ OctopusParameters ['HookUrl'] -ContentType'application / json' }
答案 0 :(得分:1)
我只需要在PowerShell Slack通知脚本中的现有Invoke-RestMethod
行之前立即插入以下行,即可使工作再次正常进行:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
有关此事的更多详细信息,请参见以下相关答案:https://stackoverflow.com/a/45692875/12484
答案 1 :(得分:0)
我使用以下代码更新模板,更新了项目步骤,并且它起作用了。
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Ssl3, [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12
Invoke-RestMethod -Method POST -Body ($payload | ConvertTo-Json -Depth 4) -Uri $OctopusParameters['HookUrl'] -ContentType 'application/json'