95 lines
2.7 KiB
Diff
95 lines
2.7 KiB
Diff
diff -rup curl-7.19.6.orig/lib/nss.c curl-7.19.6/lib/nss.c
|
|
--- curl-7.19.6.orig/lib/nss.c 2009-10-14 17:24:48.863839812 +0200
|
|
+++ curl-7.19.6/lib/nss.c 2009-10-14 17:25:29.192777766 +0200
|
|
@@ -278,6 +278,24 @@ static int is_file(const char *filename)
|
|
return 0;
|
|
}
|
|
|
|
+static char *fmt_nickname(char *str, bool *nickname_alloc)
|
|
+{
|
|
+ char *nickname = NULL;
|
|
+ *nickname_alloc = FALSE;
|
|
+
|
|
+ if(is_file(str)) {
|
|
+ char *n = strrchr(str, '/');
|
|
+ if(n) {
|
|
+ *nickname_alloc = TRUE;
|
|
+ n++; /* skip last slash */
|
|
+ nickname = aprintf("PEM Token #%d:%s", 1, n);
|
|
+ }
|
|
+ return nickname;
|
|
+ }
|
|
+
|
|
+ return str;
|
|
+}
|
|
+
|
|
static int nss_load_cert(struct ssl_connect_data *ssl,
|
|
const char *filename, PRBool cacert)
|
|
{
|
|
@@ -795,7 +813,7 @@ static SECStatus SelectClientCert(void *
|
|
return SECFailure;
|
|
}
|
|
|
|
- infof(data, "NSS: Client client certificate: %s\n", nickname);
|
|
+ infof(data, "NSS: client certificate: %s\n", nickname);
|
|
display_cert_info(data, *pRetCert);
|
|
return SECSuccess;
|
|
}
|
|
@@ -1164,24 +1182,10 @@ CURLcode Curl_nss_connect(struct connect
|
|
}
|
|
|
|
if(data->set.str[STRING_CERT]) {
|
|
- char *n;
|
|
- char *nickname;
|
|
bool nickname_alloc = FALSE;
|
|
-
|
|
- if(is_file(data->set.str[STRING_CERT])) {
|
|
- n = strrchr(data->set.str[STRING_CERT], '/');
|
|
- if(n) {
|
|
- n++; /* skip last slash */
|
|
- nickname = aprintf("PEM Token #%d:%s", 1, n);
|
|
- if(!nickname)
|
|
- return CURLE_OUT_OF_MEMORY;
|
|
-
|
|
- nickname_alloc = TRUE;
|
|
- }
|
|
- }
|
|
- else {
|
|
- nickname = data->set.str[STRING_CERT];
|
|
- }
|
|
+ char *nickname = fmt_nickname(data->set.str[STRING_CERT], &nickname_alloc);
|
|
+ if(!nickname)
|
|
+ return CURLE_OUT_OF_MEMORY;
|
|
|
|
if(!cert_stuff(conn, sockindex, data->set.str[STRING_CERT],
|
|
data->set.str[STRING_KEY])) {
|
|
@@ -1240,23 +1244,13 @@ CURLcode Curl_nss_connect(struct connect
|
|
display_conn_info(conn, connssl->handle);
|
|
|
|
if (data->set.str[STRING_SSL_ISSUERCERT]) {
|
|
- char *n;
|
|
- char *nickname;
|
|
- bool nickname_alloc = FALSE;
|
|
SECStatus ret;
|
|
+ bool nickname_alloc = FALSE;
|
|
+ char *nickname = fmt_nickname(data->set.str[STRING_SSL_ISSUERCERT],
|
|
+ &nickname_alloc);
|
|
|
|
- if(is_file(data->set.str[STRING_SSL_ISSUERCERT])) {
|
|
- n = strrchr(data->set.str[STRING_SSL_ISSUERCERT], '/');
|
|
- if (n) {
|
|
- n++; /* skip last slash */
|
|
- nickname = aprintf("PEM Token #%d:%s", 1, n);
|
|
- if(!nickname)
|
|
- return CURLE_OUT_OF_MEMORY;
|
|
- nickname_alloc = TRUE;
|
|
- }
|
|
- }
|
|
- else
|
|
- nickname = data->set.str[STRING_SSL_ISSUERCERT];
|
|
+ if(!nickname)
|
|
+ return CURLE_OUT_OF_MEMORY;
|
|
|
|
ret = check_issuer_cert(connssl->handle, nickname);
|
|
|