I am baffled, I have a web service doing a ssl connection to a website using
ssl and a certificate that came to me in a p12 format. This code worked
100% in vb.net app but fails to work in service. I keep getting 403
forbidden error when the response like is executed. I have the following
code
strInquiryData = New Uri("https://someite:308")
' Build the inquiry string
sPostData = TransConnect
' Dim wreqTU40 As HttpWebRequest =
CType(WebRequest.Create(strInquiryData), HttpWebRequest)
wreqTU40.Method = "POST"
wreqTU40.ContentType = "application/x-www-form-urlencoded"
Dim Certificate As String
Certificate = "C:\certs\TA.cer"
Dim cert As X509Certificate =
X509Certificate.CreateFromCertFile(Certificate)
wrreqTU40.ClientCertificates.Add(cert)
Dim strInquiry As System.IO.Stream = wreqTU40.GetRequestStream
'Convert the Post Data to a byte array
Dim baPostData As Byte() = System.Text.Encoding.ASCII.GetBytes(sPostData)
strInquiry.Write(baPostData, 0, sPostData.Length)
'Write the Post Data to the request stream
strInquiry.Close()
Dim wresResponse As HttpWebResponse
wresResponse = CType(wreqTU40.GetResponse(),
HttpWebResponse) ‘error happens here
It crashes at the web response area every time with 403 error, what gives? I
have checked the certificate, reinstalled it like 5 times with key and
exported it as der form. I have no other ideas. Does anyone else have one?
Thanks,
Joe