Pregunta

I'm trying to request a web service over ssl from an asp.net 4.5 application. I was issued a pkcs #12 certificate by the entity that host the web service and have installed it under Trusted Root Certification Authorities in my development box. I can add the web reference to the web service from Visual Studio but when i make a service request i get the following error message:

There was no endpoint listening at http://secure.aduana.gov.py/wsaaserver/Server that could accept the message. The cause is usually an incorrect address or SOAP action.

The code is:

protected void Button1_Click( object sender, EventArgs e ) {
    py.gov.aduana.secure.WsaaServerBeanService proxy = new py.gov.aduana.secure.WsaaServerBeanService();
    var result = proxy.loginCms( "test" );
    Response.Write( result );
}

The question in short: Apart from installing the certificate as i did, do i need to send the certificate in tehe code with the request ?

Edit: I changed my code to pass the certificate by code like

webServiceClient = new WsaaServerBeanClient( WebSvcEndpointConfigurationName, new EndpointAddress( webSvcEndpointAddress ) );
            var cert = GetCertificateByThumbprint( webSvcCertificateThumbPrint, StoreLocation.LocalMachine);
            if ( null == cert )                     
                return;           

webServiceClient.ClientCredentials.ClientCertificate.Certificate = cert;

private X509Certificate2 GetCertificateByThumbprint( string certificateThumbPrint, StoreLocation certificateStoreLocation ) {
    X509Certificate2 certificate = null;

    X509Store certificateStore = new X509Store( certificateStoreLocation );
    certificateStore.Open( OpenFlags.ReadOnly );


    X509Certificate2Collection certCollection = certificateStore.Certificates;
    foreach ( X509Certificate2 cert in certCollection ) {
        if ( cert.Thumbprint != null && cert.Thumbprint.Equals( certificateThumbPrint, StringComparison.OrdinalIgnoreCase ) ) {
            certificate = cert;
            break;
        }
    }

    if ( certificate == null ) {
        Label1.Text = string.Format("Certificate with thumbprint {0} not found", certificateThumbPrint );
    }

    return certificate;
}

But the certificate is not retrieved from the store.

¿Fue útil?

Solución

I think your url is wrong. Shouldn't it be "https://"? I get a better error message if I go to the SSL url in my browser.

Edit:

If I go to http://secure.aduana.gov.py/wsaaserver/Server, I get a 404 error:

Not Found
The requested URL /wsaaserver/Server was not found on this server.

But if I go to the SSL version at https://secure.aduana.gov.py/wsaaserver/Server, I get this message:

HTTP GET not supported

Just based on the error message, I think the SSL version is much more likely the correct URL to be using.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top