Bug 360420, OCSP Stapling, TLS client side implementation, based on work by Adam Langley, with tweaks from me and bsmith. r=rrelyea
git-svn-id: svn://10.0.0.236/trunk@264732 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -400,3 +400,6 @@ ER3(SSL_ERROR_RX_UNEXPECTED_HELLO_VERIFY_REQUEST, (SSL_ERROR_BASE + 123),
|
||||
|
||||
ER3(SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_VERSION, (SSL_ERROR_BASE + 124),
|
||||
"SSL feature not supported for the protocol version.")
|
||||
|
||||
ER3(SSL_ERROR_RX_UNEXPECTED_CERT_STATUS, (SSL_ERROR_BASE + 125),
|
||||
"SSL received an unexpected Certificate Status handshake message.")
|
||||
|
||||
@@ -156,3 +156,9 @@ SSL_SetSRTPCiphers;
|
||||
;+ local:
|
||||
;+*;
|
||||
;+};
|
||||
;+NSS_3.14.2 { # NSS 3.14.2 release
|
||||
;+ global:
|
||||
SSL_PeerStapledOCSPResponse;
|
||||
;+ local:
|
||||
;+*;
|
||||
;+};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* $Id: ssl.h,v 1.59 2012-09-21 21:58:43 wtc%google.com Exp $ */
|
||||
/* $Id: ssl.h,v 1.60 2013-02-15 17:52:45 kaie%kuix.de Exp $ */
|
||||
|
||||
#ifndef __ssl_h_
|
||||
#define __ssl_h_
|
||||
@@ -158,6 +158,7 @@ SSL_IMPORT PRFileDesc *DTLS_ImportFD(PRFileDesc *model, PRFileDesc *fd);
|
||||
* accept fragmented alerts).
|
||||
*/
|
||||
#define SSL_CBC_RANDOM_IV 23
|
||||
#define SSL_ENABLE_OCSP_STAPLING 24 /* Request OCSP stapling (client) */
|
||||
|
||||
#ifdef SSL_DEPRECATED_FUNCTION
|
||||
/* Old deprecated function names */
|
||||
@@ -397,6 +398,24 @@ SSL_IMPORT SECStatus SSL_SecurityStatus(PRFileDesc *fd, int *on, char **cipher,
|
||||
*/
|
||||
SSL_IMPORT CERTCertificate *SSL_PeerCertificate(PRFileDesc *fd);
|
||||
|
||||
/* SSL_PeerStapledOCSPResponse returns the OCSP response that was provided by
|
||||
* the TLS server. The return value is a pointer to an internal SECItem that
|
||||
* contains the returned OCSP response; it is only valid until the callback
|
||||
* function that calls SSL_PeerStapledOCSPResponse returns.
|
||||
*
|
||||
* If no OCSP response was given by the server then the result will be empty.
|
||||
* If there was an error, then the result will be NULL.
|
||||
*
|
||||
* You must set the SSL_ENABLE_OCSP_STAPLING option to enable OCSP stapling.
|
||||
* to be provided by a server.
|
||||
*
|
||||
* libssl does not do any validation of the OCSP response itself; the
|
||||
* authenticate certificate hook is responsible for doing so. The default
|
||||
* authenticate certificate hook, SSL_AuthCertificate, does not implement
|
||||
* any OCSP stapling funtionality, but this may change in future versions.
|
||||
*/
|
||||
SSL_IMPORT const SECItem * SSL_PeerStapledOCSPResponse(PRFileDesc *fd);
|
||||
|
||||
/*
|
||||
** Authenticate certificate hook. Called when a certificate comes in
|
||||
** (because of SSL_REQUIRE_CERTIFICATE in SSL_Enable) to authenticate the
|
||||
@@ -417,6 +436,16 @@ SSL_IMPORT CERTCertificate *SSL_PeerCertificate(PRFileDesc *fd);
|
||||
** See the documentation for SSL_AuthCertificateComplete for more information
|
||||
** about the asynchronous behavior that occurs when the authenticate
|
||||
** certificate hook returns SECWouldBlock.
|
||||
**
|
||||
** RFC 6066 says that clients should send the bad_certificate_status_response
|
||||
** alert when they encounter an error processing the stapled OCSP response.
|
||||
** libssl does not provide a way for the authenticate certificate hook to
|
||||
** indicate that an OCSP error (SEC_ERROR_OCSP_*) that it returns is an error
|
||||
** in the stapled OCSP response or an error in some other OCSP response.
|
||||
** Further, NSS does not provide a convenient way to control or determine
|
||||
** which OCSP response(s) were used to validate a certificate chain.
|
||||
** Consequently, the current version of libssl does not ever send the
|
||||
** bad_certificate_status_response alert. This may change in future releases.
|
||||
*/
|
||||
typedef SECStatus (PR_CALLBACK *SSLAuthCertificate)(void *arg, PRFileDesc *fd,
|
||||
PRBool checkSig,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* $Id: ssl3con.c,v 1.201 2013-02-07 01:29:19 wtc%google.com Exp $ */
|
||||
/* $Id: ssl3con.c,v 1.202 2013-02-15 17:52:45 kaie%kuix.de Exp $ */
|
||||
|
||||
/* TODO(ekr): Implement HelloVerifyRequest on server side. OK for now. */
|
||||
|
||||
@@ -8450,6 +8450,43 @@ ssl3_CleanupPeerCerts(sslSocket *ss)
|
||||
ss->ssl3.peerCertChain = NULL;
|
||||
}
|
||||
|
||||
/* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete
|
||||
* ssl3 CertificateStatus message.
|
||||
* Caller must hold Handshake and RecvBuf locks.
|
||||
* This is always called before ssl3_HandleCertificate, even if the Certificate
|
||||
* message is sent first.
|
||||
*/
|
||||
static SECStatus
|
||||
ssl3_HandleCertificateStatus(sslSocket *ss, SSL3Opaque *b, PRUint32 length)
|
||||
{
|
||||
PRInt32 status, len;
|
||||
PORT_Assert(ss->ssl3.hs.ws == wait_certificate_status);
|
||||
|
||||
/* Consume the CertificateStatusType enum */
|
||||
status = ssl3_ConsumeHandshakeNumber(ss, 1, &b, &length);
|
||||
if (status != 1 /* ocsp */) {
|
||||
goto format_loser;
|
||||
}
|
||||
|
||||
len = ssl3_ConsumeHandshakeNumber(ss, 3, &b, &length);
|
||||
if (len != length) {
|
||||
goto format_loser;
|
||||
}
|
||||
|
||||
if (SECITEM_AllocItem(NULL, &ss->sec.ci.sid->peerCertStatus, length) == NULL) {
|
||||
return SECFailure;
|
||||
}
|
||||
ss->sec.ci.sid->peerCertStatus.type = siBuffer;
|
||||
PORT_Memcpy(ss->sec.ci.sid->peerCertStatus.data, b, length);
|
||||
|
||||
return SECSuccess;
|
||||
|
||||
format_loser:
|
||||
return ssl3_DecodeError(ss);
|
||||
}
|
||||
|
||||
static SECStatus ssl3_AuthCertificate(sslSocket *ss);
|
||||
|
||||
/* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete
|
||||
* ssl3 Certificate message.
|
||||
* Caller must hold Handshake and RecvBuf locks.
|
||||
@@ -8516,7 +8553,8 @@ ssl3_HandleCertificate(sslSocket *ss, SSL3Opaque *b, PRUint32 length)
|
||||
errCode = PORT_GetError();
|
||||
goto loser;
|
||||
}
|
||||
goto server_no_cert;
|
||||
ss->ssl3.hs.ws = wait_client_key;
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
ss->ssl3.peerCertArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
|
||||
@@ -8595,6 +8633,48 @@ ssl3_HandleCertificate(sslSocket *ss, SSL3Opaque *b, PRUint32 length)
|
||||
|
||||
SECKEY_UpdateCertPQG(ss->sec.peerCert);
|
||||
|
||||
if (!isServer && ssl3_ExtensionNegotiated(ss, ssl_cert_status_xtn)) {
|
||||
ss->ssl3.hs.ws = wait_certificate_status;
|
||||
rv = SECSuccess;
|
||||
} else {
|
||||
rv = ssl3_AuthCertificate(ss); /* sets ss->ssl3.hs.ws */
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
ambiguous_err:
|
||||
errCode = PORT_GetError();
|
||||
switch (errCode) {
|
||||
case PR_OUT_OF_MEMORY_ERROR:
|
||||
case SEC_ERROR_BAD_DATABASE:
|
||||
case SEC_ERROR_NO_MEMORY:
|
||||
if (isTLS) {
|
||||
desc = internal_error;
|
||||
goto alert_loser;
|
||||
}
|
||||
goto loser;
|
||||
}
|
||||
ssl3_SendAlertForCertError(ss, errCode);
|
||||
goto loser;
|
||||
|
||||
decode_loser:
|
||||
desc = isTLS ? decode_error : bad_certificate;
|
||||
|
||||
alert_loser:
|
||||
(void)SSL3_SendAlert(ss, alert_fatal, desc);
|
||||
|
||||
loser:
|
||||
(void)ssl_MapLowLevelError(errCode);
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
static SECStatus
|
||||
ssl3_AuthCertificate(sslSocket *ss)
|
||||
{
|
||||
SECStatus rv;
|
||||
PRBool isServer = (PRBool)(!!ss->sec.isServer);
|
||||
int errCode;
|
||||
|
||||
ss->ssl3.hs.authCertificatePending = PR_FALSE;
|
||||
|
||||
/*
|
||||
@@ -8691,7 +8771,6 @@ ssl3_HandleCertificate(sslSocket *ss, SSL3Opaque *b, PRUint32 length)
|
||||
ss->ssl3.hs.ws = wait_server_key; /* allow server_key_exchange */
|
||||
}
|
||||
} else {
|
||||
server_no_cert:
|
||||
ss->ssl3.hs.ws = wait_client_key;
|
||||
}
|
||||
|
||||
@@ -8704,34 +8783,7 @@ server_no_cert:
|
||||
|
||||
return rv;
|
||||
|
||||
ambiguous_err:
|
||||
errCode = PORT_GetError();
|
||||
switch (errCode) {
|
||||
case PR_OUT_OF_MEMORY_ERROR:
|
||||
case SEC_ERROR_BAD_DATABASE:
|
||||
case SEC_ERROR_NO_MEMORY:
|
||||
if (isTLS) {
|
||||
desc = internal_error;
|
||||
goto alert_loser;
|
||||
}
|
||||
goto loser;
|
||||
}
|
||||
ssl3_SendAlertForCertError(ss, errCode);
|
||||
goto loser;
|
||||
|
||||
decode_loser:
|
||||
desc = isTLS ? decode_error : bad_certificate;
|
||||
|
||||
alert_loser:
|
||||
(void)SSL3_SendAlert(ss, alert_fatal, desc);
|
||||
|
||||
loser:
|
||||
ssl3_CleanupPeerCerts(ss);
|
||||
|
||||
if (ss->sec.peerCert != NULL) {
|
||||
CERT_DestroyCertificate(ss->sec.peerCert);
|
||||
ss->sec.peerCert = NULL;
|
||||
}
|
||||
(void)ssl_MapLowLevelError(errCode);
|
||||
return SECFailure;
|
||||
}
|
||||
@@ -9420,7 +9472,26 @@ ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length)
|
||||
}
|
||||
|
||||
PORT_SetError(0); /* each message starts with no error. */
|
||||
switch (ss->ssl3.hs.msg_type) {
|
||||
|
||||
/* The CertificateStatus message is optional. We process the message if we
|
||||
* get one when it is allowed, but otherwise we just carry on.
|
||||
*/
|
||||
if (ss->ssl3.hs.ws == wait_certificate_status) {
|
||||
/* We must process any CertificateStatus message before we call
|
||||
* ssl3_AuthCertificate, as ssl3_AuthCertificate needs any stapled OCSP
|
||||
* response we get.
|
||||
*/
|
||||
if (ss->ssl3.hs.msg_type == certificate_status) {
|
||||
rv = ssl3_HandleCertificateStatus(ss, b, length);
|
||||
if (rv != SECSuccess)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Regardless of whether we got a CertificateStatus message, we must
|
||||
* authenticate the cert before we handle any more handshake messages.
|
||||
*/
|
||||
rv = ssl3_AuthCertificate(ss); /* sets ss->ssl3.hs.ws */
|
||||
} else switch (ss->ssl3.hs.msg_type) {
|
||||
case hello_request:
|
||||
if (length != 0) {
|
||||
(void)ssl3_DecodeError(ss);
|
||||
@@ -9461,6 +9532,11 @@ ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length)
|
||||
case certificate:
|
||||
rv = ssl3_HandleCertificate(ss, b, length);
|
||||
break;
|
||||
case certificate_status:
|
||||
/* The good case is handled above */
|
||||
PORT_SetError(SSL_ERROR_RX_UNEXPECTED_CERT_STATUS);
|
||||
rv = SECFailure;
|
||||
break;
|
||||
case server_key_exchange:
|
||||
if (ss->sec.isServer) {
|
||||
(void)SSL3_SendAlert(ss, alert_fatal, unexpected_message);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* TLS extension code moved here from ssl3ecc.c */
|
||||
/* $Id: ssl3ext.c,v 1.30 2012-11-13 01:26:40 wtc%google.com Exp $ */
|
||||
/* $Id: ssl3ext.c,v 1.31 2013-02-15 17:52:45 kaie%kuix.de Exp $ */
|
||||
|
||||
#include "nssrenam.h"
|
||||
#include "nss.h"
|
||||
@@ -61,6 +61,11 @@ static PRInt32 ssl3_SendUseSRTPXtn(sslSocket *ss, PRBool append,
|
||||
PRUint32 maxBytes);
|
||||
static SECStatus ssl3_HandleUseSRTPXtn(sslSocket * ss, PRUint16 ex_type,
|
||||
SECItem *data);
|
||||
static SECStatus ssl3_ClientHandleStatusRequestXtn(sslSocket *ss,
|
||||
PRUint16 ex_type,
|
||||
SECItem *data);
|
||||
static PRInt32 ssl3_ClientSendStatusRequestXtn(sslSocket * ss, PRBool append,
|
||||
PRUint32 maxBytes);
|
||||
|
||||
/*
|
||||
* Write bytes. Using this function means the SECItem structure
|
||||
@@ -234,6 +239,7 @@ static const ssl3HelloExtensionHandler serverHelloHandlersTLS[] = {
|
||||
{ ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn },
|
||||
{ ssl_next_proto_nego_xtn, &ssl3_ClientHandleNextProtoNegoXtn },
|
||||
{ ssl_use_srtp_xtn, &ssl3_HandleUseSRTPXtn },
|
||||
{ ssl_cert_status_xtn, &ssl3_ClientHandleStatusRequestXtn },
|
||||
{ -1, NULL }
|
||||
};
|
||||
|
||||
@@ -258,7 +264,8 @@ ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = {
|
||||
#endif
|
||||
{ ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn },
|
||||
{ ssl_next_proto_nego_xtn, &ssl3_ClientSendNextProtoNegoXtn },
|
||||
{ ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn }
|
||||
{ ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn },
|
||||
{ ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn }
|
||||
/* any extra entries will appear as { 0, NULL } */
|
||||
};
|
||||
|
||||
@@ -648,6 +655,74 @@ loser:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static SECStatus
|
||||
ssl3_ClientHandleStatusRequestXtn(sslSocket *ss, PRUint16 ex_type,
|
||||
SECItem *data)
|
||||
{
|
||||
/* The echoed extension must be empty. */
|
||||
if (data->len != 0)
|
||||
return SECFailure;
|
||||
|
||||
/* Keep track of negotiated extensions. */
|
||||
ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type;
|
||||
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
/* ssl3_ClientSendStatusRequestXtn builds the status_request extension on the
|
||||
* client side. See RFC 4366 section 3.6. */
|
||||
static PRInt32
|
||||
ssl3_ClientSendStatusRequestXtn(sslSocket * ss, PRBool append,
|
||||
PRUint32 maxBytes)
|
||||
{
|
||||
PRInt32 extension_length;
|
||||
|
||||
if (!ss->opt.enableOCSPStapling)
|
||||
return 0;
|
||||
|
||||
/* extension_type (2-bytes) +
|
||||
* length(extension_data) (2-bytes) +
|
||||
* status_type (1) +
|
||||
* responder_id_list length (2) +
|
||||
* request_extensions length (2)
|
||||
*/
|
||||
extension_length = 9;
|
||||
|
||||
if (append && maxBytes >= extension_length) {
|
||||
SECStatus rv;
|
||||
TLSExtensionData *xtnData;
|
||||
|
||||
/* extension_type */
|
||||
rv = ssl3_AppendHandshakeNumber(ss, ssl_cert_status_xtn, 2);
|
||||
if (rv != SECSuccess)
|
||||
return -1;
|
||||
rv = ssl3_AppendHandshakeNumber(ss, extension_length - 4, 2);
|
||||
if (rv != SECSuccess)
|
||||
return -1;
|
||||
rv = ssl3_AppendHandshakeNumber(ss, 1 /* status_type ocsp */, 1);
|
||||
if (rv != SECSuccess)
|
||||
return -1;
|
||||
/* A zero length responder_id_list means that the responders are
|
||||
* implicitly known to the server. */
|
||||
rv = ssl3_AppendHandshakeNumber(ss, 0, 2);
|
||||
if (rv != SECSuccess)
|
||||
return -1;
|
||||
/* A zero length request_extensions means that there are no extensions.
|
||||
* Specifically, we don't set the id-pkix-ocsp-nonce extension. This
|
||||
* means that the server can replay a cached OCSP response to us. */
|
||||
rv = ssl3_AppendHandshakeNumber(ss, 0, 2);
|
||||
if (rv != SECSuccess)
|
||||
return -1;
|
||||
|
||||
xtnData = &ss->xtnData;
|
||||
xtnData->advertised[xtnData->numAdvertised++] = ssl_cert_status_xtn;
|
||||
} else if (maxBytes < extension_length) {
|
||||
PORT_Assert(0);
|
||||
return 0;
|
||||
}
|
||||
return extension_length;
|
||||
}
|
||||
|
||||
/*
|
||||
* NewSessionTicket
|
||||
* Called from ssl3_HandleFinished
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* $Id: ssl3prot.h,v 1.22 2012-04-25 14:50:12 gerv%gerv.net Exp $ */
|
||||
/* $Id: ssl3prot.h,v 1.23 2013-02-15 17:52:45 kaie%kuix.de Exp $ */
|
||||
|
||||
#ifndef __ssl3proto_h_
|
||||
#define __ssl3proto_h_
|
||||
@@ -129,6 +129,7 @@ typedef enum {
|
||||
certificate_verify = 15,
|
||||
client_key_exchange = 16,
|
||||
finished = 20,
|
||||
certificate_status = 22,
|
||||
next_proto = 67
|
||||
} SSL3HandshakeType;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* $Id: sslerr.h,v 1.25 2012-07-13 00:51:57 wtc%google.com Exp $ */
|
||||
/* $Id: sslerr.h,v 1.26 2013-02-15 17:52:45 kaie%kuix.de Exp $ */
|
||||
#ifndef __SSL_ERR_H_
|
||||
#define __SSL_ERR_H_
|
||||
|
||||
@@ -188,6 +188,8 @@ SSL_ERROR_RX_UNEXPECTED_HELLO_VERIFY_REQUEST = (SSL_ERROR_BASE + 123),
|
||||
|
||||
SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_VERSION = (SSL_ERROR_BASE + 124),
|
||||
|
||||
SSL_ERROR_RX_UNEXPECTED_CERT_STATUS = (SSL_ERROR_BASE + 125),
|
||||
|
||||
SSL_ERROR_END_OF_LIST /* let the c compiler determine the value of this. */
|
||||
} SSLErrorCodes;
|
||||
#endif /* NO_SECURITY_ERROR_ENUM */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* $Id: sslimpl.h,v 1.109 2012-11-14 01:14:12 wtc%google.com Exp $ */
|
||||
/* $Id: sslimpl.h,v 1.110 2013-02-15 17:52:45 kaie%kuix.de Exp $ */
|
||||
|
||||
#ifndef __sslimpl_h_
|
||||
#define __sslimpl_h_
|
||||
@@ -316,6 +316,7 @@ typedef struct sslOptionsStr {
|
||||
unsigned int requireSafeNegotiation : 1; /* 22 */
|
||||
unsigned int enableFalseStart : 1; /* 23 */
|
||||
unsigned int cbcRandomIV : 1; /* 24 */
|
||||
unsigned int enableOCSPStapling : 1; /* 25 */
|
||||
} sslOptions;
|
||||
|
||||
typedef enum { sslHandshakingUndetermined = 0,
|
||||
@@ -575,6 +576,7 @@ struct sslSessionIDStr {
|
||||
sslSessionID * next; /* chain used for client sockets, only */
|
||||
|
||||
CERTCertificate * peerCert;
|
||||
SECItem peerCertStatus; /* client only */
|
||||
const char * peerID; /* client only */
|
||||
const char * urlSvrName; /* client only */
|
||||
CERTCertificate * localCert;
|
||||
@@ -717,6 +719,7 @@ typedef enum {
|
||||
wait_change_cipher,
|
||||
wait_finished,
|
||||
wait_server_hello,
|
||||
wait_certificate_status,
|
||||
wait_server_cert,
|
||||
wait_server_key,
|
||||
wait_cert_request,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* $Id: sslnonce.c,v 1.28 2012-11-14 01:14:12 wtc%google.com Exp $ */
|
||||
/* $Id: sslnonce.c,v 1.29 2013-02-15 17:52:45 kaie%kuix.de Exp $ */
|
||||
|
||||
#include "cert.h"
|
||||
#include "pk11pub.h"
|
||||
@@ -184,6 +184,8 @@ ssl_DestroySID(sslSessionID *sid)
|
||||
if ( sid->peerCert ) {
|
||||
CERT_DestroyCertificate(sid->peerCert);
|
||||
}
|
||||
SECITEM_FreeItem(&sid->peerCertStatus, PR_FALSE);
|
||||
|
||||
if ( sid->localCert ) {
|
||||
CERT_DestroyCertificate(sid->localCert);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* $Id: sslsock.c,v 1.99 2012-12-20 20:29:36 bsmith%mozilla.com Exp $ */
|
||||
/* $Id: sslsock.c,v 1.100 2013-02-15 17:52:45 kaie%kuix.de Exp $ */
|
||||
#include "seccomon.h"
|
||||
#include "cert.h"
|
||||
#include "keyhi.h"
|
||||
@@ -153,7 +153,8 @@ static sslOptions ssl_defaults = {
|
||||
2, /* enableRenegotiation (default: requires extension) */
|
||||
PR_FALSE, /* requireSafeNegotiation */
|
||||
PR_FALSE, /* enableFalseStart */
|
||||
PR_TRUE /* cbcRandomIV */
|
||||
PR_TRUE, /* cbcRandomIV */
|
||||
PR_FALSE /* enableOCSPStapling */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -827,6 +828,10 @@ SSL_OptionSet(PRFileDesc *fd, PRInt32 which, PRBool on)
|
||||
ss->opt.cbcRandomIV = on;
|
||||
break;
|
||||
|
||||
case SSL_ENABLE_OCSP_STAPLING:
|
||||
ss->opt.enableOCSPStapling = on;
|
||||
break;
|
||||
|
||||
default:
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
rv = SECFailure;
|
||||
@@ -896,6 +901,7 @@ SSL_OptionGet(PRFileDesc *fd, PRInt32 which, PRBool *pOn)
|
||||
on = ss->opt.requireSafeNegotiation; break;
|
||||
case SSL_ENABLE_FALSE_START: on = ss->opt.enableFalseStart; break;
|
||||
case SSL_CBC_RANDOM_IV: on = ss->opt.cbcRandomIV; break;
|
||||
case SSL_ENABLE_OCSP_STAPLING: on = ss->opt.enableOCSPStapling; break;
|
||||
|
||||
default:
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
@@ -954,6 +960,9 @@ SSL_OptionGetDefault(PRInt32 which, PRBool *pOn)
|
||||
break;
|
||||
case SSL_ENABLE_FALSE_START: on = ssl_defaults.enableFalseStart; break;
|
||||
case SSL_CBC_RANDOM_IV: on = ssl_defaults.cbcRandomIV; break;
|
||||
case SSL_ENABLE_OCSP_STAPLING:
|
||||
on = ssl_defaults.enableOCSPStapling;
|
||||
break;
|
||||
|
||||
default:
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
@@ -1117,6 +1126,10 @@ SSL_OptionSetDefault(PRInt32 which, PRBool on)
|
||||
ssl_defaults.cbcRandomIV = on;
|
||||
break;
|
||||
|
||||
case SSL_ENABLE_OCSP_STAPLING:
|
||||
ssl_defaults.enableOCSPStapling = on;
|
||||
break;
|
||||
|
||||
default:
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return SECFailure;
|
||||
@@ -1853,6 +1866,25 @@ SSL_VersionRangeSet(PRFileDesc *fd, const SSLVersionRange *vrange)
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
const SECItem *
|
||||
SSL_PeerStapledOCSPResponse(PRFileDesc *fd)
|
||||
{
|
||||
sslSocket *ss = ssl_FindSocket(fd);
|
||||
|
||||
if (!ss) {
|
||||
SSL_DBG(("%d: SSL[%d]: bad socket in SSL_GetStapledOCSPResponse",
|
||||
SSL_GETPID(), fd));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ss->sec.ci.sid) {
|
||||
PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &ss->sec.ci.sid->peerCertStatus;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* The following functions are the TOP LEVEL SSL functions.
|
||||
** They all get called through the NSPRIOMethods table below.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* $Id: sslt.h,v 1.23 2012-06-07 02:06:19 wtc%google.com Exp $ */
|
||||
/* $Id: sslt.h,v 1.24 2013-02-15 17:52:45 kaie%kuix.de Exp $ */
|
||||
|
||||
#ifndef __sslt_h_
|
||||
#define __sslt_h_
|
||||
@@ -175,6 +175,7 @@ typedef enum {
|
||||
/* Update SSL_MAX_EXTENSIONS whenever a new extension type is added. */
|
||||
typedef enum {
|
||||
ssl_server_name_xtn = 0,
|
||||
ssl_cert_status_xtn = 5,
|
||||
#ifdef NSS_ENABLE_ECC
|
||||
ssl_elliptic_curves_xtn = 10,
|
||||
ssl_ec_point_formats_xtn = 11,
|
||||
@@ -185,6 +186,6 @@ typedef enum {
|
||||
ssl_renegotiation_info_xtn = 0xff01 /* experimental number */
|
||||
} SSLExtensionType;
|
||||
|
||||
#define SSL_MAX_EXTENSIONS 7
|
||||
#define SSL_MAX_EXTENSIONS 8
|
||||
|
||||
#endif /* __sslt_h_ */
|
||||
|
||||
Reference in New Issue
Block a user