Bonjour,

J'ai développé un serveur de service en utilisant GSoap et avec une identification SSL.
Tout fonctionnait correctement jusqu'a ce que mes certificats (clients et serveur) soient expirés.

Dans mon cas les clients sont des serveurs apache.

Voici le code C++
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
        //initialisation du context
	if ( soap_ssl_server_context(m_pSoap,
									SOAP_SSL_DEFAULT | SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION | SOAP_SSL_NO_DEFAULT_CA_PATH,
									sslFile.c_str(), /* keyfile: required when server must authenticate to clients (see SSL docs on how to obtain this file) */
									("myPassword").c_str(), /* password to read the key file */
									caCertFile.c_str(), /* optional cacert file to store trusted certificates */
									NULL, /* optional capath to directory with trusted certificates */
									NULL, /* DH file name or DH key len bits (minimum is 512, e.g. "512") to generate DH param, if NULL use RSA */
									NULL, /* if randfile!=NULL: use a file with random data to seed randomness */
									NULL /* optional server identification to enable SSL session cache (must be a unique name) */    ))
 
...
 
//puis réception d'une requete
#ifdef WITH_OPENSSL
			if ( soap_ssl_accept( pSoapCopy ) ){ ... }

Si mes certificats sont expirés j'ai le message d'erreur:
SSL routines:SSL3_READ_BYTES:sslv3 alert certificate expired


Coté PHP:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
			$context = stream_context_create(array(
					'ssl' => array(
							'verify_peer' => true,
							'allow_self_signed' => true,
							'cafile' => $caFilePath,
                            'disable_compression'=> true
					)
			));
 
			$options = array("exceptions" => 1,
							"local_cert" => $sslCertPath,
							"myPassword",
    					    'stream_context' => $context,
							'location' => $this->getWsdlHost() . '/' . $iServiceName ,
                            'cache_wsdl' =>  WSDL_CACHE_MEMORY );

J'ai réussi à faire fonctionné client et serveur en mode debug en modifiant coté PHP:
'verify_peer' => true,
en
'verify_peer' => false,

En Release, ca ne ne marche plus.
Pour faire fonctionner le Release je suis obligé de commenté #ifdef SOAP_DEBUG dans le fichier stdsoap2.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
#ifdef WITH_OPENSSL
#ifndef PALM_1
static int
ssl_verify_callback(int ok, X509_STORE_CTX *store)
{
//#ifdef SOAP_DEBUG
  if (!ok)
  { char buf[1024];
    int err = X509_STORE_CTX_get_error(store);
    X509 *cert = X509_STORE_CTX_get_current_cert(store);
    fprintf(stderr, "SSL verify error or warning with certificate at depth %d: %s\n", X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(err));
    X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf));
    fprintf(stderr, "certificate issuer %s\n", buf);
    X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf));
    fprintf(stderr, "certificate subject %s\n", buf);
    /* accept self signed certificates and certificates out of date */
    switch (err)
    { case X509_V_ERR_CERT_NOT_YET_VALID:
      case X509_V_ERR_CERT_HAS_EXPIRED:
      case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
      case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
        X509_STORE_CTX_set_error(store, X509_V_OK);
        ok = 1;
    }
  }
//#endif
  /* Note: return 1 to continue, but unsafe progress will be terminated by OpenSSL */
  return ok;
}
#endif
#endif

Y aurait-il des paramètres de context à passer client ou serveur.
J'ai essayé d'ajouter SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE dans le context du serveur, mais ca à l'air d'être un paramètre uniquement client.
coté PHP je n'ai pas encore trouvé quelque chose de similaire.