curl-users
[PATCH] nss: refuse previously loaded certificate from file
From: Kamil Dudka <kdudka_at_redhat.com>
Date: Mon, 22 Aug 2016 10:24:35 +0200
Date: Mon, 22 Aug 2016 10:24:35 +0200
... when we are not asked to use a certificate from file
--- lib/vtls/nss.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c index ad33f25..e467360 100644 --- a/lib/vtls/nss.c +++ b/lib/vtls/nss.c @@ -1004,10 +1004,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; @@ -1069,6 +1069,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; -- 2.7.4 --nextPart5440679.A0VIfQE1iZ Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLQpMaXN0IGFkbWluOiBodHRwczovL2Nvb2wuaGF4eC5zZS9saXN0L2xpc3RpbmZv L2N1cmwtdXNlcnMKRkFROiAgICAgICAgaHR0cHM6Ly9jdXJsLmhheHguc2UvZG9jcy9mYXEuaHRt bApFdGlxdWV0dGU6ICBodHRwczovL2N1cmwuaGF4eC5zZS9tYWlsL2V0aXF1ZXR0ZS5odG1sCg== --nextPart5440679.A0VIfQE1iZ--Received on 2001-09-17