How do you POST a file to a secure website using a digital certifi

G

Guest

I have been struggling with this for a couple of weeks.

I have a digital certificate installed in my certificate collection store on
my local computer. The site I am trying to post to also has our certificate
installed is said it is ready to recieve transactions. I have created a file
(xml) and I want to post to the given web address.

An example of the web address is https://some.company.com/location

this is what I have tried:
aStreamReader = New StreamReader("C:\MyTest2.txt")
postData = aStreamReader.ReadToEnd()
Dim data As Byte() = encoding.GetBytes(postData)

Dim myRequest As HttpWebRequest = _
CType(WebRequest.Create("https://some.company.com/location"), _

HttpWebRequest)
myRequest.ClientCertificates.Add( _

Security.Cryptography.X509Certificates.X509Certificate.CreateFromSignedFile _

("C:\MyDigitalCertificate.cer"))
myRequest.Method = "POST"
myRequest.KeepAlive = False

'*******ERROR occurs on this next line when getting request stream******
Dim newStream As Stream = myRequest.GetRequestStream
' Send the data.
newStream.Write(data, 0, data.Length)
newStream.Close()

The error is:
The underlying connection was closed: Could not establish secure channel
for SSL/TLS.

What am i missing? Is there any examples or articles that would help me?
Has anyone else ran into this and could shed some light on this? Am I just
way off on doing this?
 
J

Joerg Jooss

Hello Paul,
I have been struggling with this for a couple of weeks.

I have a digital certificate installed in my certificate collection
store on my local computer. The site I am trying to post to also has
our certificate installed is said it is ready to recieve transactions.
I have created a file (xml) and I want to post to the given web
address.

An example of the web address is https://some.company.com/location

this is what I have tried:
aStreamReader = New StreamReader("C:\MyTest2.txt")
postData = aStreamReader.ReadToEnd()
Dim data As Byte() = encoding.GetBytes(postData)
Dim myRequest As HttpWebRequest = _
CType(WebRequest.Create("https://some.company.com/location"), _
HttpWebRequest)
myRequest.ClientCertificates.Add( _
Security.Cryptography.X509Certificates.X509Certificate.CreateFromSigne
dFile _

("C:\MyDigitalCertificate.cer"))
myRequest.Method = "POST"
myRequest.KeepAlive = False
'*******ERROR occurs on this next line when getting request
stream******
Dim newStream As Stream = myRequest.GetRequestStream
' Send the data.
newStream.Write(data, 0, data.Length)
newStream.Close()
The error is:
The underlying connection was closed: Could not establish secure
channel
for SSL/TLS.

Does the certificate work in a web browser? It seems the SSL handshake fails
right away.

Cheers,
 
G

Guest

The webserver I am trying to get to doesn't allow browsing to it via a web
browser.

Paul
 
J

Joerg Jooss

Hello Paul,
The webserver I am trying to get to doesn't allow browsing to it via a
web browser.

And how is that implemented? Or is there simply no browseable contents? There
must be some way of verifying that the site is accessible, otherwise it's
pretty hard to figure out where your problem lies.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top