ASP.NET and SSL

J

Jalyah

English:
Hi! I have a problem when I send a request from an asp page to another
with HttpWebRequest. The site requires a certicate to access, for
this reason I added a certificate to the request using the class
X509Certificate. The problem is that I get a 403 forbidden error
message. I guess that is a permission matter. I also tried to create
a component service to do it, but I obtain the same error message.
You have the code here, thanks in advance.

Spanish:
Hola! Tengo un problema al enviar una petición de una página asp a
otra con HttpWebRequest. El sitio requiere de certificados para poder
entrar, así que a la petición le añado un certificado para que me
permita abrir la página asp. El problema es que me da un error 403 de
prohibido. Supongo que será por algún tema de permisos pero no se
solucionarlo. También he intentado crear un servicio de componente
que lo haga, pero me da el mismo error. Aquí os dejo el código para
ver si le podeis echar un vistazo.

The code:

Dim datos, respuesta As String
Dim webReq As HttpWebRequest
Dim webResp As HttpWebResponse
Dim sw As Stream
Dim sr As StreamReader
Dim encodedData As New ASCIIEncoding

Dim byteArray As Byte() = encodedData.GetBytes(datos)

webReq = HttpWebRequest.Create(url)
webReq.Method = "POST"
webReq.Timeout = 60000
webReq.ContentLength = byteArray.Length
webReq.ContentType = "application/x-www-form-urlencoded"

Dim cert = X509Certificate.CreateFromCertFile(pathcertificado)
webReq.ClientCertificates.Add(cert)

webReq.AllowWriteStreamBuffering = False
sw = webReq.GetRequestStream()
sw.Write(byteArray, 0, byteArray.Length)
sw.Close()

'Obtenemos la respuesta del servidor
webResp = webReq.GetResponse()
sr = New StreamReader(webResp.GetResponseStream())
respuesta = sr.ReadToEnd()
sr.Close()



Gracias. Thanks
 

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