Skip to content

Commit 172b2be

Browse files
committed
SSL: Add an option to disable certificate revocation checks
New tool option --ssl-no-revoke. New value CURLSSLOPT_NO_REVOKE for CURLOPT_SSL_OPTIONS. Currently this option applies only to WinSSL where we have automatic certificate revocation checking by default. According to the ssl-compared chart there are other backends that have automatic checking (NSS, wolfSSL and DarwinSSL) so we could possibly accommodate them at some later point. Bug: #264 Reported-by: zenden2k <[email protected]>
1 parent 606b29f commit 172b2be

15 files changed

Lines changed: 129 additions & 23 deletions

File tree

‎docs/SSL-PROBLEMS‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,17 @@ Allow BEAST
7171
introduced. Exactly as it sounds, it re-introduces the BEAST vulnerability
7272
but on the other hand it allows curl to connect to that kind of strange
7373
servers.
74+
75+
Disabling certificate revocation checks
76+
77+
Some SSL backends may do certificate revocation checks (CRL, OCSP, etc)
78+
depending on the OS or build configuration. The --ssl-no-revoke option was
79+
introduced in 7.44.0 to disable revocation checking but currently is only
80+
supported for WinSSL (the native Windows SSL library), with an exception in
81+
the case of Windows' Untrusted Publishers blacklist which it seems can't be
82+
bypassed. This option may have broader support to accommodate other SSL
83+
backends in the future.
84+
85+
References:
86+
87+
http://curl.haxx.se/docs/ssl-compared.html

‎docs/curl.1‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,10 @@ and TLS1.0 protocols known as BEAST. If this option isn't used, the SSL layer
15451545
may use workarounds known to cause interoperability problems with some older
15461546
SSL implementations. WARNING: this option loosens the SSL security, and by
15471547
using this flag you ask for exactly that. (Added in 7.25.0)
1548+
.IP "--ssl-no-revoke"
1549+
(WinSSL) This option tells curl to disable certificate revocation checks.
1550+
WARNING: this option loosens the SSL security, and by using this flag you ask
1551+
for exactly that. (Added in 7.44.0)
15481552
.IP "--socks4 <host[:port]>"
15491553
Use the specified SOCKS4 proxy. If the port number is not specified, it is
15501554
assumed at port 1080. (Added in 7.15.2)

‎docs/libcurl/opts/CURLOPT_SSL_OPTIONS.3‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,25 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_OPTIONS, long bitmask);
3030
.SH DESCRIPTION
3131
Pass a long with a bitmask to tell libcurl about specific SSL behaviors.
3232

33-
\fICURLSSLOPT_ALLOW_BEAST\fP is the only supported bit and by setting this the
34-
user will tell libcurl to not attempt to use any workarounds for a security
35-
flaw in the SSL3 and TLS1.0 protocols. If this option isn't used or this bit
36-
is set to 0, the SSL layer libcurl uses may use a work-around for this flaw
37-
although it might cause interoperability problems with some (older) SSL
38-
implementations. WARNING: avoiding this work-around lessens the security, and
39-
by setting this option to 1 you ask for exactly that.
33+
\fICURLSSLOPT_ALLOW_BEAST\fP tells libcurl to not attempt to use any
34+
workarounds for a security flaw in the SSL3 and TLS1.0 protocols. If this
35+
option isn't used or this bit is set to 0, the SSL layer libcurl uses may use a
36+
work-around for this flaw although it might cause interoperability problems
37+
with some (older) SSL implementations. WARNING: avoiding this work-around
38+
lessens the security, and by setting this option to 1 you ask for exactly that.
39+
This option is only supported for DarwinSSL, NSS and OpenSSL.
40+
41+
Added in 7.44.0:
42+
43+
\fICURLSSLOPT_NO_REVOKE\fP tells libcurl to disable certificate revocation
44+
checks for those SSL backends where such behavior is present. \fBCurrently this
45+
option is only supported for WinSSL (the native Windows SSL library), with an
46+
exception in the case of Windows' Untrusted Publishers blacklist which it seems
47+
can't be bypassed.\fP This option may have broader support to accommodate other
48+
SSL backends in the future.
49+
http://curl.haxx.se/docs/ssl-compared.html
50+
51+
4052
.SH DEFAULT
4153
0
4254
.SH PROTOCOLS

‎include/curl/curl.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,10 @@ typedef enum {
725725
servers, a user can this way allow the vulnerability back. */
726726
#define CURLSSLOPT_ALLOW_BEAST (1<<0)
727727

728+
/* - NO_REVOKE tells libcurl to disable certificate revocation checks for those
729+
SSL backends where such behavior is present. */
730+
#define CURLSSLOPT_NO_REVOKE (1<<1)
731+
728732
#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
729733
the obsolete stuff removed! */
730734

‎lib/url.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
22342234

22352235
case CURLOPT_SSL_OPTIONS:
22362236
arg = va_arg(param, long);
2237-
data->set.ssl_enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
2237+
data->set.ssl_enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST);
2238+
data->set.ssl_no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
22382239
break;
22392240

22402241
#endif

‎lib/urldata.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,7 @@ struct UserDefined {
15821582
bool connect_only; /* make connection, let application use the socket */
15831583
bool ssl_enable_beast; /* especially allow this flaw for interoperability's
15841584
sake*/
1585+
bool ssl_no_revoke; /* disable SSL certificate revocation checks */
15851586
long ssh_auth_types; /* allowed SSH auth types */
15861587
bool http_te_skip; /* pass the raw body data to the user, even when
15871588
transfer-encoded (chunked, compressed) */

‎lib/vtls/schannel.c‎

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,24 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
128128
SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
129129
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
130130
#else
131-
schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION |
132-
SCH_CRED_REVOCATION_CHECK_CHAIN;
131+
schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION;
132+
if(data->set.ssl_no_revoke)
133+
schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
134+
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
135+
else
136+
schannel_cred.dwFlags |= SCH_CRED_REVOCATION_CHECK_CHAIN;
133137
#endif
134-
infof(data, "schannel: checking server certificate revocation\n");
138+
if(data->set.ssl_no_revoke)
139+
infof(data, "schannel: disabled server certificate revocation "
140+
"checks\n");
141+
else
142+
infof(data, "schannel: checking server certificate revocation\n");
135143
}
136144
else {
137145
schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION |
138146
SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
139147
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
140-
infof(data, "schannel: disable server certificate revocation checks\n");
148+
infof(data, "schannel: disabled server certificate revocation checks\n");
141149
}
142150

143151
if(!data->set.ssl.verifyhost) {
@@ -1384,7 +1392,8 @@ static CURLcode verify_certificate(struct connectdata *conn, int sockindex)
13841392
NULL,
13851393
pCertContextServer->hCertStore,
13861394
&ChainPara,
1387-
0,
1395+
(data->set.ssl_no_revoke ? 0 :
1396+
CERT_CHAIN_REVOCATION_CHECK_CHAIN),
13881397
NULL,
13891398
&pChainContext)) {
13901399
failf(data, "schannel: CertGetCertificateChain failed: %s",
@@ -1395,21 +1404,24 @@ static CURLcode verify_certificate(struct connectdata *conn, int sockindex)
13951404

13961405
if(result == CURLE_OK) {
13971406
CERT_SIMPLE_CHAIN *pSimpleChain = pChainContext->rgpChain[0];
1398-
DWORD dwTrustErrorMask = ~(DWORD)(CERT_TRUST_IS_NOT_TIME_NESTED|
1399-
CERT_TRUST_REVOCATION_STATUS_UNKNOWN);
1407+
DWORD dwTrustErrorMask = ~(DWORD)(CERT_TRUST_IS_NOT_TIME_NESTED);
14001408
dwTrustErrorMask &= pSimpleChain->TrustStatus.dwErrorStatus;
14011409
if(dwTrustErrorMask) {
1402-
if(dwTrustErrorMask & CERT_TRUST_IS_PARTIAL_CHAIN)
1410+
if(dwTrustErrorMask & CERT_TRUST_IS_REVOKED)
1411+
failf(data, "schannel: CertGetCertificateChain trust error"
1412+
" CERT_TRUST_IS_REVOKED");
1413+
else if(dwTrustErrorMask & CERT_TRUST_IS_PARTIAL_CHAIN)
14031414
failf(data, "schannel: CertGetCertificateChain trust error"
14041415
" CERT_TRUST_IS_PARTIAL_CHAIN");
1405-
if(dwTrustErrorMask & CERT_TRUST_IS_UNTRUSTED_ROOT)
1416+
else if(dwTrustErrorMask & CERT_TRUST_IS_UNTRUSTED_ROOT)
14061417
failf(data, "schannel: CertGetCertificateChain trust error"
14071418
" CERT_TRUST_IS_UNTRUSTED_ROOT");
1408-
if(dwTrustErrorMask & CERT_TRUST_IS_NOT_TIME_VALID)
1419+
else if(dwTrustErrorMask & CERT_TRUST_IS_NOT_TIME_VALID)
14091420
failf(data, "schannel: CertGetCertificateChain trust error"
14101421
" CERT_TRUST_IS_NOT_TIME_VALID");
1411-
failf(data, "schannel: CertGetCertificateChain error mask: 0x%08x",
1412-
dwTrustErrorMask);
1422+
else
1423+
failf(data, "schannel: CertGetCertificateChain error mask: 0x%08x",
1424+
dwTrustErrorMask);
14131425
result = CURLE_PEER_FAILED_VERIFICATION;
14141426
}
14151427
}
@@ -1425,6 +1437,14 @@ static CURLcode verify_certificate(struct connectdata *conn, int sockindex)
14251437
cert_hostname.const_tchar_ptr = cert_hostname_buff;
14261438
hostname.tchar_ptr = Curl_convert_UTF8_to_tchar(conn->host.name);
14271439

1440+
/* TODO: Fix this for certificates with multiple alternative names.
1441+
Right now we're only asking for the first preferred alternative name.
1442+
Instead we'd need to do all via CERT_NAME_SEARCH_ALL_NAMES_FLAG
1443+
(if WinCE supports that?) and run this section in a loop for each.
1444+
https://msdn.microsoft.com/en-us/library/windows/desktop/aa376086.aspx
1445+
curl: (51) schannel: CertGetNameString() certificate hostname
1446+
(.google.com) did not match connection (google.com)
1447+
*/
14281448
len = CertGetNameString(pCertContextServer,
14291449
CERT_NAME_DNS_TYPE,
14301450
0,

‎src/tool_cfgable.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ struct OperationConfig {
199199
bool xattr; /* store metadata in extended attributes */
200200
long gssapi_delegation;
201201
bool ssl_allow_beast; /* allow this SSL vulnerability */
202+
bool ssl_no_revoke; /* disable SSL certificate revocation checks */
202203

203204
bool use_metalink; /* process given URLs as metalink XML file */
204205
metalinkfile *metalinkfile_list; /* point to the first node */

‎src/tool_getparam.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ static const struct LongShort aliases[]= {
221221
{"Ep", "pinnedpubkey", TRUE},
222222
{"Eq", "cert-status", FALSE},
223223
{"Er", "false-start", FALSE},
224+
{"Es", "ssl-no-revoke", FALSE},
224225
{"f", "fail", FALSE},
225226
{"F", "form", TRUE},
226227
{"Fs", "form-string", TRUE},
@@ -1382,6 +1383,11 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
13821383
config->falsestart = TRUE;
13831384
break;
13841385

1386+
case 's': /* --ssl-no-revoke */
1387+
if(curlinfo->features & CURL_VERSION_SSL)
1388+
config->ssl_no_revoke = TRUE;
1389+
break;
1390+
13851391
default: /* certificate file */
13861392
{
13871393
char *certname, *passphrase;

‎src/tool_help.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ static const char *const helptext[] = {
214214
" -2, --sslv2 Use SSLv2 (SSL)",
215215
" -3, --sslv3 Use SSLv3 (SSL)",
216216
" --ssl-allow-beast Allow security flaw to improve interop (SSL)",
217+
" --ssl-no-revoke Disable cert revocation checks (WinSSL)",
217218
" --stderr FILE Where to redirect stderr (use \"-\" for stdout)",
218219
" --tcp-nodelay Use the TCP_NODELAY option",
219220
" -t, --telnet-option OPT=VAL Set telnet option",

0 commit comments

Comments
 (0)