Can't establish SSL connection to web service C# -
i'm trying connect web-service. i'm new ssl stuff. here's code:
public void sendrequest(string httpsurl, string postdata, string[] certificates, string password) { httpwebrequest request = (httpwebrequest)webrequest.create(httpsurl); request.method = "post"; byte[] bytearray = encoding.utf8.getbytes(postdata); request.contenttype = "application/x-www-form-urlencoded"; request.contentlength = bytearray.length; x509certificate certificate = null; foreach (string cert in certificates) { certificate = new x509certificate(cert, password); request.clientcertificates.add(certificate); //add cert } stream datastream = request.getrequeststream(); datastream.write(bytearray, 0, bytearray.length); datastream.close(); }
the request.getrequeststream()
throws exception: "the underlying connection closed: not establish trust relationship ssl/tls secure channel".
certificates given me web service provider (.cer files), password (key.dat), think might private key.
any ideas why throws error? doing wrong?
Comments
Post a Comment