Could not create SSL/TLS secure channel, despite setting ServerCertificateValidationCallback

后端 未结 8 1566
醉酒成梦
醉酒成梦 2020-12-04 17:29

I\'m trying to establish SSL/TLS connection to test server with self-signed certificate. Communication through unsecure channel worked without issues.

8条回答
  •  [愿得一人]
    2020-12-04 18:06

    I came across this thread because I also had the error Could not create SSL/TLS secure channel. In my case, I was attempting to access a Siebel configuration REST API from PowerShell using Invoke-RestMethod, and none of the suggestions above helped.

    Eventually I stumbled across the cause of my problem: the server I was contacting required client certificate authentication.

    To make the calls work, I had to provide the client certificate (including the private key) with the -Certificate parameter:

    $Pwd = 'certificatepassword'
    $Pfx = New-Object -TypeName 'System.Security.Cryptography.X509Certificates.X509Certificate2'
    $Pfx.Import('clientcert.p12', $Pwd, 'Exportable,PersistKeySet')
    Invoke-RestMethod -Uri 'https://your.rest.host/api/' -Certificate $Pfx -OtherParam ...
    

    Hopefully my experience might help someone else who has my particular flavour of this problem.

提交回复
热议问题