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

后端 未结 8 1534
醉酒成梦
醉酒成梦 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:05

    If you are using a new domain name, and you have done all the above and you are still getting the same error, check to see if you clear the DNS cache on your PC. Clear your DNS for more details.

    Windows® 8

    To clear your DNS cache if you use Windows 8, perform the following steps:

    On your keyboard, press Win+X to open the WinX Menu.

    Right-click Command Prompt and select Run as Administrator.

    Run the following command:

    ipconfig /flushdns

    If the command succeeds, the system returns the following message:

    Windows IP configuration successfully flushed the DNS Resolver Cache.

    Windows® 7

    To clear your DNS cache if you use Windows 7, perform the following steps:

    Click Start.

    Enter cmd in the Start menu search text box.

    Right-click Command Prompt and select Run as Administrator.

    Run the following command:

    ipconfig /flushdns

    If the command succeeds, the system returns the following message: Windows IP configuration successfully flushed the DNS Resolver Cache.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题