locked
HOW TO ADD CERTIFICATES TO HttpWebRequest REQUEST TO A HTTPS WEBSERVER RRS feed

  • Question

  • Am trying to send certificates while making a web service call using the but keep getting the error The request was aborted: Could not create SSL/TLS secure channel.

            Dim req As HttpWebRequest = HttpWebRequest.CreateDefault(New System.Uri(cred.endpoint))
            Dim root As X509Certificate2 = New X509Certificate2()
            Dim policy As X509Certificate2 = New X509Certificate2()
            Dim issue As X509Certificate2 = New X509Certificate2()
            Dim certv As X509Certificate2 = New X509Certificate2()
    
            Dim rootStore As New X509Store(StoreName.Root, StoreLocation.LocalMachine)
            rootStore.Open(OpenFlags.ReadOnly)
            root = rootStore.Certificates.Find(X509FindType.FindByIssuerName, "ROOT-CA", True)(0)
            Dim intmStore As New X509Store(StoreName.CertificateAuthority, StoreLocation.LocalMachine)
            intmStore.Open(OpenFlags.ReadOnly)
            policy = intmStore.Certificates.Find(X509FindType.FindByIssuerName, "ROOT-CA", True)(0)
            issue = intmStore.Certificates.Find(X509FindType.FindByIssuerName, "POLICY-CA", True)(0)
            certv = intmStore.Certificates.Find(X509FindType.FindByIssuerName, "ISSUECA05-CA", True)(0)
            req.ClientCertificates.Add(root)
            req.ClientCertificates.Add(policy)
            req.ClientCertificates.Add(issue)
            req.ClientCertificates.Add(certv)
            req.Headers.Add("SOAP:Action")
            req.ContentType = "text/xml; charset=utf-8"
            req.Accept = "text/xml"
            req.Method = "POST"
            ServicePointManager.Expect100Continue = True
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
            ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications
            Dim soapXML As New System.Xml.XmlDocument
            soapXML.LoadXml(txn)
            Dim strm As Stream = req.GetRequestStream()
            soapXML.Save(strm)
    
            Dim resp = req.GetResponse()
            Dim stread As StreamReader = New StreamReader(resp.GetResponseStream())
            Dim st As String = stread.ReadToEnd()

    When I check the trace logs from wireshark i notice that the certficate length is 0 when does that mean am not sending the certificate.


    • Moved by Youjun Tang Friday, April 3, 2015 9:32 AM more related to the suggested forum
    Thursday, March 26, 2015 2:28 PM

All replies