简体   繁体   中英

c++ - Can't access gSOAP web services with HTTPS

I'm trying to hit a web service which I built with SSL on gSOAP 2.8.4. But it doesn't works. Relevant information:

  • Everything works fine using HTTP. The problem only happens when I use HTTPS.
  • Message error:

Error -1 fault: SOAP-ENV:Client [no subcode] "End of file or no input: Operation interrupted or timed out (60 s receive delay) (60 s send delay)" Detail: [no detail]

The problem doesn't seem to be a low timeout because the error is instantaneous.

Server context:

if (soap_ssl_server_context(&soap,
    SOAP_SSL_DEFAULT,   /* use SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION to verify clients: client must provide a key file e.g. "client.pem" and "password" */
    "server.pem",   /* keyfile (cert+key): see SSL docs to create this file */
    password,       /* password to read the private key in the key file */
    "cacert.pem",   /* cacert file to store trusted certificates (to authenticate clients) */
    "./",       /* capath */
    NULL,   /* DH file name or DH param key len bits (e.g. "1024"), if NULL use RSA 2048 bits (SOAP_SSL_RSA_BITS) */
    NULL,       /* if randfile!=NULL: use a file with random data to seed randomness */
    "server"        /* server identification for SSL session cache (unique server name, e.g. use argv[0]) */
    ))
{

Client context:

if (soap_ssl_client_context(&soap,
    SOAP_SSL_DEFAULT,   /* use SOAP_SSL_DEFAULT in production code */
    NULL,       /* keyfile (cert+key): required only when client must authenticate to server (see SSL docs to create this file) */
    NULL,       /* password to read the keyfile */
    "cacert.pem",   /* optional cacert file to store trusted certificates, use cacerts.pem for all public certificates issued by common CAs */
    "./",       /* optional capath to directory with trusted certificates */
    NULL        /* if randfile!=NULL: use a file with random data to seed randomness */
    ))
{

All the certificates and passwords are correct. What could be the problem?


Edit: I compiled the code with -DDEBUG. This appears in TEST.log

Free ID hashtable Read 0 bytes from socket=4/fd=0 Sending back fault struct for error code -1 soap_instantiate_SOAP_ENV__Fault(-1, , )

I already solved this problem. The server certificate was wrong. The Common Name in this application should be equal to the host name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM