2 * NSS utility functions
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
20 * Look to see if any of the signers in the cert chain for "cert" are found
21 * in the list of caNames.
22 * Returns SECSuccess if so, SECFailure if not.
25 NSS_CmpCertChainWCANames(CERTCertificate
*cert
, CERTDistNames
*caNames
)
28 CERTCertificate
* curcert
;
29 CERTCertificate
* oldcert
;
36 SECItem compatIssuerName
;
38 if (!cert
|| !caNames
|| !caNames
->nnames
|| !caNames
->names
||
39 !caNames
->names
->data
)
42 curcert
= CERT_DupCertificate(cert
);
45 issuerName
= curcert
->derIssuer
;
47 /* compute an alternate issuer name for compatibility with 2.0
48 * enterprise server, which send the CA names without
49 * the outer layer of DER header
51 rv
= DER_Lengths(&issuerName
, &headerlen
, (PRUint32
*)&contentlen
);
52 if ( rv
== SECSuccess
) {
53 compatIssuerName
.data
= &issuerName
.data
[headerlen
];
54 compatIssuerName
.len
= issuerName
.len
- headerlen
;
56 compatIssuerName
.data
= NULL
;
57 compatIssuerName
.len
= 0;
60 for (j
= 0; j
< caNames
->nnames
; j
++) {
61 caname
= &caNames
->names
[j
];
62 if (SECITEM_CompareItem(&issuerName
, caname
) == SECEqual
) {
64 CERT_DestroyCertificate(curcert
);
66 } else if (SECITEM_CompareItem(&compatIssuerName
, caname
) == SECEqual
) {
68 CERT_DestroyCertificate(curcert
);
72 if ( ( depth
<= 20 ) &&
73 ( SECITEM_CompareItem(&curcert
->derIssuer
, &curcert
->derSubject
)
76 curcert
= CERT_FindCertByName(curcert
->dbhandle
,
78 CERT_DestroyCertificate(oldcert
);
81 CERT_DestroyCertificate(curcert
);