From: Scott Cantor Date: Thu, 5 Feb 2009 16:43:10 +0000 (+0000) Subject: Set no_ticket option where possible, to avoid openssl bug connecting to older servers. X-Git-Tag: 1.2.0~34 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=commitdiff_plain;h=a09dd66b6dcd3fd0ed0bf532fdb10542e5ababc3 Set no_ticket option where possible, to avoid openssl bug connecting to older servers. --- diff --git a/xmltooling/soap/impl/CURLSOAPTransport.cpp b/xmltooling/soap/impl/CURLSOAPTransport.cpp index 5e0a656..90e8223 100644 --- a/xmltooling/soap/impl/CURLSOAPTransport.cpp +++ b/xmltooling/soap/impl/CURLSOAPTransport.cpp @@ -308,7 +308,6 @@ CURL* CURLPool::get(const SOAPTransport::Address& addr) curl_easy_setopt(handle,CURLOPT_NOPROGRESS,1); curl_easy_setopt(handle,CURLOPT_NOSIGNAL,1); curl_easy_setopt(handle,CURLOPT_FAILONERROR,1); - curl_easy_setopt(handle,CURLOPT_SSLVERSION,CURL_SSLVERSION_SSLv3); curl_easy_setopt(handle,CURLOPT_SSL_CIPHER_LIST,"ALL:!aNULL:!LOW:!EXPORT:!SSLv2"); // Verification of the peer is via TrustEngine only. curl_easy_setopt(handle,CURLOPT_SSL_VERIFYPEER,0); @@ -593,6 +592,15 @@ CURLcode xmltooling::xml_ssl_ctx_callback(CURL* curl, SSL_CTX* ssl_ctx, void* us { CURLSOAPTransport* conf = reinterpret_cast(userptr); + // Manually disable SSLv2 so we're not dependent on libcurl to do it. + // Also disable the ticket option where implemented, since this breaks a variety + // of servers. Newer libcurl also does this for us. +#ifdef SSL_OP_NO_TICKET + SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET); +#else + SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL|SSL_OP_NO_SSLv2); +#endif + #ifndef XMLTOOLING_NO_XMLSEC if (conf->m_cred) conf->m_cred->attach(ssl_ctx); diff --git a/xmltooling/util/CurlURLInputStream.cpp b/xmltooling/util/CurlURLInputStream.cpp index 7b84e91..fa4f2cb 100644 --- a/xmltooling/util/CurlURLInputStream.cpp +++ b/xmltooling/util/CurlURLInputStream.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -47,6 +48,21 @@ namespace { static const XMLCh uri[] = UNICODE_LITERAL_3(u,r,i); static const XMLCh url[] = UNICODE_LITERAL_3(u,r,l); static const XMLCh verifyHost[] = UNICODE_LITERAL_10(v,e,r,i,f,y,H,o,s,t); + + // callback to invoke a caller-defined SSL callback + CURLcode ssl_ctx_callback(CURL* curl, SSL_CTX* ssl_ctx, void* userptr) + { + // Manually disable SSLv2 so we're not dependent on libcurl to do it. + // Also disable the ticket option where implemented, since this breaks a variety + // of servers. Newer libcurl also does this for us. +#ifdef SSL_OP_NO_TICKET + SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET); +#else + SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL|SSL_OP_NO_SSLv2); +#endif + + return CURLE_OK; + } } CurlURLInputStream::CurlURLInputStream(const char* url) @@ -160,6 +176,9 @@ void CurlURLInputStream::init(const DOMElement* e) curl_easy_setopt(fEasy, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(fEasy, CURLOPT_FAILONERROR, 1); + // Install SSL callback. + curl_easy_setopt(fEasy, CURLOPT_SSL_CTX_FUNCTION, ssl_ctx_callback); + fError[0] = 0; curl_easy_setopt(fEasy, CURLOPT_ERRORBUFFER, fError);