Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Unified Diff: net/third_party/nss/ssl/sslauth.c

Issue 25107004: Change SSL_PeerCertificateChain to return a CERTCertList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Sync Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/third_party/nss/ssl/ssl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/third_party/nss/ssl/sslauth.c
===================================================================
--- net/third_party/nss/ssl/sslauth.c (revision 226069)
+++ net/third_party/nss/ssl/sslauth.c (working copy)
@@ -28,38 +28,43 @@
}
/* NEED LOCKS IN HERE. */
-SECStatus
-SSL_PeerCertificateChain(PRFileDesc *fd, CERTCertificate **certs,
- unsigned int *numCerts, unsigned int maxNumCerts)
+CERTCertList *
+SSL_PeerCertificateChain(PRFileDesc *fd)
{
sslSocket *ss;
- ssl3CertNode* cur;
+ CERTCertList *chain = NULL;
+ CERTCertificate *cert;
+ ssl3CertNode *cur;
ss = ssl_FindSocket(fd);
if (!ss) {
SSL_DBG(("%d: SSL[%d]: bad socket in PeerCertificateChain",
SSL_GETPID(), fd));
- return SECFailure;
+ return NULL;
}
- if (!ss->opt.useSecurity)
- return SECFailure;
-
- if (ss->sec.peerCert == NULL) {
- *numCerts = 0;
- return SECSuccess;
+ if (!ss->opt.useSecurity || !ss->sec.peerCert) {
+ PORT_SetError(SSL_ERROR_NO_CERTIFICATE);
+ return NULL;
}
-
- *numCerts = 1; /* for the leaf certificate */
- if (maxNumCerts > 0)
- certs[0] = CERT_DupCertificate(ss->sec.peerCert);
-
+ chain = CERT_NewCertList();
+ if (!chain) {
+ return NULL;
+ }
+ cert = CERT_DupCertificate(ss->sec.peerCert);
+ if (CERT_AddCertToListTail(chain, cert) != SECSuccess) {
+ goto loser;
+ }
for (cur = ss->ssl3.peerCertChain; cur; cur = cur->next) {
- if (*numCerts < maxNumCerts)
- certs[*numCerts] = CERT_DupCertificate(cur->cert);
- (*numCerts)++;
+ cert = CERT_DupCertificate(cur->cert);
+ if (CERT_AddCertToListTail(chain, cert) != SECSuccess) {
+ goto loser;
+ }
}
+ return chain;
- return SECSuccess;
+loser:
+ CERT_DestroyCertList(chain);
+ return NULL;
}
/* NEED LOCKS IN HERE. */
« no previous file with comments | « net/third_party/nss/ssl/ssl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698