#include <certdb.h>
#include <base64.h>
#include <cert.h>
+#include <prerror.h>
#include "curl_memory.h"
#include "rawstr.h"
static const char* pem_library = "libnsspem.so";
SECMODModule* mod = NULL;
+static const char* nss_error_to_name(PRErrorCode code)
+{
+ const char *name = PR_ErrorToName(code);
+ if(name)
+ return name;
+
+ return "unknown error";
+}
+
static SECStatus set_ciphers(struct SessionHandle *data, PRFileDesc * model,
char *cipher_list)
{
if(cert_file) {
rv = nss_load_cert(&conn->ssl[sockindex], cert_file, PR_FALSE);
if(CURLE_OK != rv) {
- if(!display_error(conn, PR_GetError(), cert_file))
- failf(data, "Unable to load client cert %d.", PR_GetError());
+ const PRErrorCode err = PR_GetError();
+ if(!display_error(conn, err, cert_file)) {
+ const char *err_name = nss_error_to_name(err);
+ failf(data, "unable to load client cert: %d (%s)", err, err_name);
+ }
return rv;
}
/* In case the cert file also has the key */
rv = nss_load_key(conn, sockindex, cert_file);
if(CURLE_OK != rv) {
- if(!display_error(conn, PR_GetError(), key_file))
- failf(data, "Unable to load client key %d.", PR_GetError());
+ const PRErrorCode err = PR_GetError();
+ if(!display_error(conn, err, key_file)) {
+ const char *err_name = nss_error_to_name(err);
+ failf(data, "unable to load client key: %d (%s)", err, err_name);
+ }
return rv;
}
if(handle_cc_error(err, data))
curlerr = CURLE_SSL_CERTPROBLEM;
else
- infof(data, "NSS error %d\n", err);
+ infof(data, "NSS error %d (%s)\n", err, nss_error_to_name(err));
if(model)
PR_Close(model);
else if(handle_cc_error(err, conn->data))
*curlcode = CURLE_SSL_CERTPROBLEM;
else {
- failf(conn->data, "SSL write: error %d", err);
+ const char *err_name = nss_error_to_name(err);
+ failf(conn->data, "SSL write: error %d (%s)", err, err_name);
*curlcode = CURLE_SEND_ERROR;
}
return -1;
else if(handle_cc_error(err, conn->data))
*curlcode = CURLE_SSL_CERTPROBLEM;
else {
- failf(conn->data, "SSL read: errno %d", err);
+ const char *err_name = nss_error_to_name(err);
+ failf(conn->data, "SSL read: errno %d (%s)", err, err_name);
*curlcode = CURLE_RECV_ERROR;
}
return -1;