code style cleanup

This commit is contained in:
Daniel Stenberg
2008-06-06 20:57:32 +00:00
parent 621c2b9015
commit a2e45a2211

View File

@@ -313,16 +313,20 @@ nss_load_cert(const char *filename, PRBool cacert)
return 0; return 0;
} }
PK11_SETATTRS(attrs, CKA_CLASS, &objClass, sizeof(objClass) ); attrs++; PK11_SETATTRS(attrs, CKA_CLASS, &objClass, sizeof(objClass) );
PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) ); attrs++; attrs++;
PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) );
attrs++;
PK11_SETATTRS(attrs, CKA_LABEL, (unsigned char *)filename, PK11_SETATTRS(attrs, CKA_LABEL, (unsigned char *)filename,
strlen(filename)+1); attrs++; strlen(filename)+1);
attrs++;
if(cacert) { if(cacert) {
PK11_SETATTRS(attrs, CKA_TRUST, &cktrue, sizeof(CK_BBOOL) ); attrs++; PK11_SETATTRS(attrs, CKA_TRUST, &cktrue, sizeof(CK_BBOOL) );
} }
else { else {
PK11_SETATTRS(attrs, CKA_TRUST, &ckfalse, sizeof(CK_BBOOL) ); attrs++; PK11_SETATTRS(attrs, CKA_TRUST, &ckfalse, sizeof(CK_BBOOL) );
} }
attrs++;
/* This load the certificate in our PEM module into the appropriate /* This load the certificate in our PEM module into the appropriate
* slot. * slot.
@@ -382,38 +386,49 @@ static int nss_load_crl(char* crlfilename, PRBool ascii)
} }
crlDER.data = NULL; crlDER.data = NULL;
prstat = PR_GetOpenFileInfo(infile,&info); prstat = PR_GetOpenFileInfo(infile,&info);
if (prstat!=PR_SUCCESS) return 0; if (prstat!=PR_SUCCESS)
return 0;
if (ascii) { if (ascii) {
SECItem filedata; SECItem filedata;
char *asc,*body; char *asc,*body;
filedata.data = NULL; filedata.data = NULL;
if (!SECITEM_AllocItem(NULL,&filedata,info.size)) return 0; if (!SECITEM_AllocItem(NULL,&filedata,info.size))
nb = PR_Read(infile,filedata.data,info.size);
if (nb!=info.size) return 0;
asc = (char*)filedata.data;
if (!asc) {
return 0; return 0;
} nb = PR_Read(infile,filedata.data,info.size);
if ((body=strstr(asc,"-----BEGIN")) != NULL) { if (nb!=info.size)
return 0;
asc = (char*)filedata.data;
if (!asc)
return 0;
body=strstr(asc,"-----BEGIN");
if (body != NULL) {
char *trailer=NULL; char *trailer=NULL;
asc = body; asc = body;
body = PORT_Strchr(asc,'\n'); body = PORT_Strchr(asc,'\n');
if (!body) body = PORT_Strchr(asc,'\r'); if (!body)
if (body) trailer = strstr(++body,"-----END"); body = PORT_Strchr(asc,'\r');
if (trailer!=NULL) *trailer='\0'; if (body)
else return 0; trailer = strstr(++body,"-----END");
if (trailer!=NULL)
*trailer='\0';
else
return 0;
} }
else { else {
body = asc; body = asc;
} }
rv = ATOB_ConvertAsciiToItem(&crlDER,body); rv = ATOB_ConvertAsciiToItem(&crlDER,body);
PORT_Free(filedata.data); PORT_Free(filedata.data);
if (rv) return 0; if (rv)
return 0;
} }
else { else {
if (!SECITEM_AllocItem(NULL,&crlDER,info.size)) return 0; if (!SECITEM_AllocItem(NULL,&crlDER,info.size))
return 0;
nb = PR_Read(infile,crlDER.data,info.size); nb = PR_Read(infile,crlDER.data,info.size);
if (nb!=info.size) return 0; if (nb!=info.size)
return 0;
} }
slot = PK11_GetInternalKeySlot(); slot = PK11_GetInternalKeySlot();
@@ -686,10 +701,10 @@ static void display_conn_info(struct connectdata *conn, PRFileDesc *sock)
PRTime notBefore, notAfter; PRTime notBefore, notAfter;
if(SSL_GetChannelInfo(sock, &channel, sizeof channel) == if(SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
SECSuccess && channel.length == sizeof channel && SECSuccess && channel.length == sizeof channel &&
channel.cipherSuite) { channel.cipherSuite) {
if(SSL_GetCipherSuiteInfo(channel.cipherSuite, if(SSL_GetCipherSuiteInfo(channel.cipherSuite,
&suite, sizeof suite) == SECSuccess) { &suite, sizeof suite) == SECSuccess) {
infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName); infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
} }
} }
@@ -728,7 +743,8 @@ static void display_conn_info(struct connectdata *conn, PRFileDesc *sock)
* issuer check, so we provide comments that mimic the OpenSSL * issuer check, so we provide comments that mimic the OpenSSL
* X509_check_issued function (in x509v3/v3_purp.c) * X509_check_issued function (in x509v3/v3_purp.c)
*/ */
static SECStatus check_issuer_cert(struct connectdata *conn, PRFileDesc *sock, char* issuer_nickname) static SECStatus check_issuer_cert(struct connectdata *conn, PRFileDesc *sock,
char* issuer_nickname)
{ {
CERTCertificate *cert,*cert_issuer,*issuer; CERTCertificate *cert,*cert_issuer,*issuer;
SECStatus res=SECSuccess; SECStatus res=SECSuccess;
@@ -1046,8 +1062,8 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
rc = nss_load_cert(fullpath, PR_TRUE); rc = nss_load_cert(fullpath, PR_TRUE);
/* FIXME: check this return value! */ /* FIXME: check this return value! */
} }
/* This is purposefully tolerant of errors so non-PEM files /* This is purposefully tolerant of errors so non-PEM files
* can be in the same directory */ * can be in the same directory */
} while(entry != NULL); } while(entry != NULL);
PR_CloseDir(dir); PR_CloseDir(dir);
} }