]> granicus.if.org Git - curl/commitdiff
nss: refuse previously loaded certificate from file
authorKamil Dudka <kdudka@redhat.com>
Mon, 22 Aug 2016 08:24:35 +0000 (10:24 +0200)
committerKamil Dudka <kdudka@redhat.com>
Fri, 26 Aug 2016 11:30:27 +0000 (13:30 +0200)
... when we are not asked to use a certificate from file

RELEASE-NOTES
lib/vtls/nss.c

index ae49a0588c2a6e819bac749dd6f3bf60b5de231b..b8a98a99e746696a458c82019e78c447d49cd491 100644 (file)
@@ -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:
 
index 20c4277ce4ab95f1c51ed19109d95392647633d1..cfb226328f71e943b7c8f1d3631c2b55da595c10 100644 (file)
@@ -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;
@@ -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;