Skip to content

Commit

Permalink
nss: refuse previously loaded certificate from file
Browse files Browse the repository at this point in the history
... when we are not asked to use a certificate from file
  • Loading branch information
kdudka committed Aug 26, 2016
1 parent 822082d commit 7700fcb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE-NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ This release includes the following bugfixes:
o SOCKS: display the hostname returned by the SOCKS5 proxy server
o sasl: Don't use GSSAPI authentication when domain name not specified [16]
o win: Basic support for Universal Windows Platform apps [17]
o nss: fix incorrect use of a previously loaded certificate from file

This release includes the following known bugs:

Expand Down
8 changes: 7 additions & 1 deletion lib/vtls/nss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,10 +1002,10 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
struct ssl_connect_data *connssl = (struct ssl_connect_data *)arg;
struct Curl_easy *data = connssl->data;
const char *nickname = connssl->client_nickname;
static const char pem_slotname[] = "PEM Token #1";

if(connssl->obj_clicert) {
/* use the cert/key provided by PEM reader */
static const char pem_slotname[] = "PEM Token #1";
SECItem cert_der = { 0, NULL, 0 };
void *proto_win = SSL_RevealPinArg(sock);
struct CERTCertificateStr *cert;
Expand Down Expand Up @@ -1067,6 +1067,12 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
if(NULL == nickname)
nickname = "[unknown]";

if(!strncmp(nickname, pem_slotname, sizeof(pem_slotname) - 1U)) {
failf(data, "NSS: refusing previously loaded certificate from file: %s",
nickname);
return SECFailure;
}

if(NULL == *pRetKey) {
failf(data, "NSS: private key not found for certificate: %s", nickname);
return SECFailure;
Expand Down

0 comments on commit 7700fcb

Please sign in to comment.