Visual Basic - WebService con certificado.

Life is soft - evento anual de software empresarial
 
Vista:
Imágen de perfil de Jon ander Garcia Ruesgas

WebService con certificado.

Publicado por Jon ander Garcia Ruesgas (1 intervención) el 02/12/2014 10:40:13
Buenos dias,

Antes de nada gracias por la posible ayuda que me podrais aportar.

Bueno empiezo a contaros lo que no consigo hacer, Estoy intentando llamar a un servicio web firmado con la firma binaria de un certificado pfx, y ando bastante perdido porque es la primera vez que lo hago y no se muy bien como hacerlo, Mirando por internet he hecho lo que poner pero aun asi me da errores. El codigo que tengo hecho es el siguiente:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Dim Servicio As New servicio_web.SEFServices_SERGAS
        Dim objStore As New X509Store(StoreName.TrustedPeople)
        Dim certificados As New X509CertificateCollection
        Dim respuesta As New servicio_web.SEFResponse
        Try
            objStore.Open(OpenFlags.ReadOnly)
            certificados = objStore.Certificates.Find(X509FindType.FindBySubjectName, "WSF_061", False)
            objStore.Close()
            Servicio.ClientCertificates.Add(certificados(0))
 
            Dim strCert As New X509SecurityToken(certificados(0))
            Dim sig As New MessageSignature(strCert)
            sig.SignatureOptions = SignatureOptions.IncludeSoapBody Or SignatureOptions.IncludeTimestamp
 
 
            Servicio.Url = "https://swifform.conselleriadefacenda.es/eFacturaWebService/SEFServices_sergas.asmx"
 
            Servicio.RequestSoapContext.Security.Tokens.Add(strCert)
            Servicio.RequestSoapContext.Security.Elements.Add(sig)
            respuesta = Servicio.SEF_ObtenerFactura("0623", "733e5d29e147c9f02ef01569cd92ad100dd50dee")
            tb1.Text = respuesta.Resultado
        Catch ex As HttpListenerException
            tb1.Text = ex.Message
            Tb2.Text = "1"
        Catch ex1 As WebException
            tb1.Text = ex1.Message
            Tb2.Text = "2"
        Catch ex3 As HostProtectionException
            tb1.Text = ex3.Message
            Tb2.Text = "3"
        Catch ex4 As HttpRequestValidationException
            tb1.Text = ex4.Message
            Tb2.Text = "4"
        Catch ex2 As Exception
            tb1.Text = ex2.Message
            Tb2.Text = "5"
        End Try
y el error que me da es: WSE3003: The certificate's trust chain could not be verified. Please check if the certificate has been properly installed in the Trusted People Certificate store. Or you might want to set allowTestRoot configuration section to true if this is a test certificate.

El certificado esta bien instalado en el almacen de personas de confianza (del equipo local y del usuario).

Ese error me da si quito el bloque try, Si lo pongo el error que me da es: WSE910: An error happened during the processing of a response message, and you can find the error in the inner exception. You can also find the response message in the Response property.

¿Podriais echarme una mano?

Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder