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

Side by Side Diff: mozilla/security/nss/lib/certhigh/certvfy.c

Issue 12197027: Merge NSS_3_14_2_RTM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #include "nspr.h" 4 #include "nspr.h"
5 #include "secerr.h" 5 #include "secerr.h"
6 #include "secport.h" 6 #include "secport.h"
7 #include "seccomon.h" 7 #include "seccomon.h"
8 #include "secoid.h" 8 #include "secoid.h"
9 #include "sslerr.h" 9 #include "sslerr.h"
10 #include "genname.h" 10 #include "genname.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 int pathLengthLimit = CERT_UNLIMITED_PATH_CONSTRAINT; 364 int pathLengthLimit = CERT_UNLIMITED_PATH_CONSTRAINT;
365 unsigned int caCertType; 365 unsigned int caCertType;
366 unsigned int requiredCAKeyUsage; 366 unsigned int requiredCAKeyUsage;
367 unsigned int requiredFlags; 367 unsigned int requiredFlags;
368 PRArenaPool *arena = NULL; 368 PRArenaPool *arena = NULL;
369 CERTGeneralName *namesList = NULL; 369 CERTGeneralName *namesList = NULL;
370 CERTCertificate **certsList = NULL; 370 CERTCertificate **certsList = NULL;
371 int certsListLen = 16; 371 int certsListLen = 16;
372 int namesCount = 0; 372 int namesCount = 0;
373 PRBool subjectCertIsSelfIssued; 373 PRBool subjectCertIsSelfIssued;
374 CERTCertTrust issuerTrust;
374 375
375 if (revoked) { 376 if (revoked) {
376 *revoked = PR_FALSE; 377 *revoked = PR_FALSE;
377 } 378 }
378 379
379 if (CERT_KeyUsageAndTypeForCertUsage(certUsage, PR_TRUE, 380 if (CERT_KeyUsageAndTypeForCertUsage(certUsage, PR_TRUE,
380 &requiredCAKeyUsage, 381 &requiredCAKeyUsage,
381 &caCertType) 382 &caCertType)
382 != SECSuccess ) { 383 != SECSuccess ) {
383 PORT_Assert(0); 384 PORT_Assert(0);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 * error to the user, but the user may wish to continue 565 * error to the user, but the user may wish to continue
565 * processing, in which case we better make sure nothing 566 * processing, in which case we better make sure nothing
566 * worse has happened... so keep cranking the loop */ 567 * worse has happened... so keep cranking the loop */
567 rvFinal = SECFailure; 568 rvFinal = SECFailure;
568 if (revoked) { 569 if (revoked) {
569 *revoked = PR_TRUE; 570 *revoked = PR_TRUE;
570 } 571 }
571 LOG_ERROR(log,subjectCert,count,0); 572 LOG_ERROR(log,subjectCert,count,0);
572 } 573 }
573 574
574 » if ( issuerCert->trust ) { 575 » if ( CERT_GetCertTrust(issuerCert, &issuerTrust) == SECSuccess) {
575 /* we have some trust info, but this does NOT imply that this 576 /* we have some trust info, but this does NOT imply that this
576 * cert is actually trusted for any purpose. The cert may be 577 * cert is actually trusted for any purpose. The cert may be
577 * explicitly UNtrusted. We won't know until we examine the 578 * explicitly UNtrusted. We won't know until we examine the
578 * trust bits. 579 * trust bits.
579 */ 580 */
580 unsigned int flags; 581 unsigned int flags;
581 582
582 if (certUsage != certUsageAnyCA && 583 if (certUsage != certUsageAnyCA &&
583 certUsage != certUsageStatusResponder) { 584 certUsage != certUsageStatusResponder) {
584 585
585 /* 586 /*
586 * XXX This choice of trustType seems arbitrary. 587 * XXX This choice of trustType seems arbitrary.
587 */ 588 */
588 if ( certUsage == certUsageVerifyCA ) { 589 if ( certUsage == certUsageVerifyCA ) {
589 if ( subjectCert->nsCertType & NS_CERT_TYPE_EMAIL_CA ) { 590 if ( subjectCert->nsCertType & NS_CERT_TYPE_EMAIL_CA ) {
590 trustType = trustEmail; 591 trustType = trustEmail;
591 } else if ( subjectCert->nsCertType & NS_CERT_TYPE_SSL_CA ) { 592 } else if ( subjectCert->nsCertType & NS_CERT_TYPE_SSL_CA ) {
592 trustType = trustSSL; 593 trustType = trustSSL;
593 } else { 594 } else {
594 trustType = trustObjectSigning; 595 trustType = trustObjectSigning;
595 } 596 }
596 } 597 }
597 598
598 » flags = SEC_GET_TRUST_FLAGS(issuerCert->trust, trustType); 599 » flags = SEC_GET_TRUST_FLAGS(&issuerTrust, trustType);
599 if (( flags & requiredFlags ) == requiredFlags) { 600 if (( flags & requiredFlags ) == requiredFlags) {
600 /* we found a trusted one, so return */ 601 /* we found a trusted one, so return */
601 rv = rvFinal; 602 rv = rvFinal;
602 goto done; 603 goto done;
603 } 604 }
604 if (flags & CERTDB_VALID_CA) { 605 if (flags & CERTDB_VALID_CA) {
605 validCAOverride = PR_TRUE; 606 validCAOverride = PR_TRUE;
606 } 607 }
607 /* is it explicitly distrusted? */ 608 /* is it explicitly distrusted? */
608 if ((flags & CERTDB_TERMINAL_RECORD) && 609 if ((flags & CERTDB_TERMINAL_RECORD) &&
609 ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0)) { 610 ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0)) {
610 /* untrusted -- the cert is explicitly untrusted, not 611 /* untrusted -- the cert is explicitly untrusted, not
611 * just that it doesn't chain to a trusted cert */ 612 * just that it doesn't chain to a trusted cert */
612 PORT_SetError(SEC_ERROR_UNTRUSTED_ISSUER); 613 PORT_SetError(SEC_ERROR_UNTRUSTED_ISSUER);
613 LOG_ERROR_OR_EXIT(log,issuerCert,count+1,flags); 614 LOG_ERROR_OR_EXIT(log,issuerCert,count+1,flags);
614 } 615 }
615 } else { 616 } else {
616 /* Check if we have any valid trust when cheching for 617 /* Check if we have any valid trust when cheching for
617 * certUsageAnyCA or certUsageStatusResponder. */ 618 * certUsageAnyCA or certUsageStatusResponder. */
618 for (trustType = trustSSL; trustType < trustTypeNone; 619 for (trustType = trustSSL; trustType < trustTypeNone;
619 trustType++) { 620 trustType++) {
620 flags = SEC_GET_TRUST_FLAGS(issuerCert->trust, trustType); 621 flags = SEC_GET_TRUST_FLAGS(&issuerTrust, trustType);
621 if ((flags & requiredFlags) == requiredFlags) { 622 if ((flags & requiredFlags) == requiredFlags) {
622 rv = rvFinal; 623 rv = rvFinal;
623 goto done; 624 goto done;
624 } 625 }
625 if (flags & CERTDB_VALID_CA) 626 if (flags & CERTDB_VALID_CA)
626 validCAOverride = PR_TRUE; 627 validCAOverride = PR_TRUE;
627 } 628 }
628 /* We have 2 separate loops because we want any single trust 629 /* We have 2 separate loops because we want any single trust
629 * bit to allow this usage to return trusted. Only if none of 630 * bit to allow this usage to return trusted. Only if none of
630 * the trust bits are on do we check to see if the cert is 631 * the trust bits are on do we check to see if the cert is
631 * untrusted */ 632 * untrusted */
632 for (trustType = trustSSL; trustType < trustTypeNone; 633 for (trustType = trustSSL; trustType < trustTypeNone;
633 trustType++) { 634 trustType++) {
634 flags = SEC_GET_TRUST_FLAGS(issuerCert->trust, trustType); 635 flags = SEC_GET_TRUST_FLAGS(&issuerTrust, trustType);
635 /* is it explicitly distrusted? */ 636 /* is it explicitly distrusted? */
636 if ((flags & CERTDB_TERMINAL_RECORD) && 637 if ((flags & CERTDB_TERMINAL_RECORD) &&
637 ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0)) { 638 ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0)) {
638 /* untrusted -- the cert is explicitly untrusted, not 639 /* untrusted -- the cert is explicitly untrusted, not
639 * just that it doesn't chain to a trusted cert */ 640 * just that it doesn't chain to a trusted cert */
640 PORT_SetError(SEC_ERROR_UNTRUSTED_ISSUER); 641 PORT_SetError(SEC_ERROR_UNTRUSTED_ISSUER);
641 LOG_ERROR_OR_EXIT(log,issuerCert,count+1,flags); 642 LOG_ERROR_OR_EXIT(log,issuerCert,count+1,flags);
642 } 643 }
643 } 644 }
644 } 645 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 CERTBasicConstraints basicConstraint; 766 CERTBasicConstraints basicConstraint;
766 PRBool isca; 767 PRBool isca;
767 PRBool validCAOverride = PR_FALSE; 768 PRBool validCAOverride = PR_FALSE;
768 SECStatus rv; 769 SECStatus rv;
769 SECStatus rvFinal = SECSuccess; 770 SECStatus rvFinal = SECSuccess;
770 unsigned int flags; 771 unsigned int flags;
771 unsigned int caCertType; 772 unsigned int caCertType;
772 unsigned int requiredCAKeyUsage; 773 unsigned int requiredCAKeyUsage;
773 unsigned int requiredFlags; 774 unsigned int requiredFlags;
774 CERTCertificate *issuerCert; 775 CERTCertificate *issuerCert;
776 CERTCertTrust certTrust;
775 777
776 778
777 if (CERT_KeyUsageAndTypeForCertUsage(certUsage, PR_TRUE, 779 if (CERT_KeyUsageAndTypeForCertUsage(certUsage, PR_TRUE,
778 &requiredCAKeyUsage, 780 &requiredCAKeyUsage,
779 &caCertType) != SECSuccess ) { 781 &caCertType) != SECSuccess ) {
780 PORT_Assert(0); 782 PORT_Assert(0);
781 EXIT_IF_NOT_LOGGING(log); 783 EXIT_IF_NOT_LOGGING(log);
782 requiredCAKeyUsage = 0; 784 requiredCAKeyUsage = 0;
783 caCertType = 0; 785 caCertType = 0;
784 } 786 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 } else { 832 } else {
831 if ( basicConstraint.isCA == PR_FALSE ) { 833 if ( basicConstraint.isCA == PR_FALSE ) {
832 PORT_SetError (SEC_ERROR_CA_CERT_INVALID); 834 PORT_SetError (SEC_ERROR_CA_CERT_INVALID);
833 LOG_ERROR_OR_EXIT(log,cert,0,0); 835 LOG_ERROR_OR_EXIT(log,cert,0,0);
834 } 836 }
835 837
836 /* can't check path length if we don't know the previous path */ 838 /* can't check path length if we don't know the previous path */
837 isca = PR_TRUE; 839 isca = PR_TRUE;
838 } 840 }
839 841
840 if ( cert->trust ) { 842 if ( CERT_GetCertTrust(cert, &certTrust) == SECSuccess ) {
841 /* we have some trust info, but this does NOT imply that this 843 /* we have some trust info, but this does NOT imply that this
842 * cert is actually trusted for any purpose. The cert may be 844 * cert is actually trusted for any purpose. The cert may be
843 * explicitly UNtrusted. We won't know until we examine the 845 * explicitly UNtrusted. We won't know until we examine the
844 * trust bits. 846 * trust bits.
845 */ 847 */
846 if (certUsage == certUsageStatusResponder) { 848 if (certUsage == certUsageStatusResponder) {
847 /* Check the special case of certUsageStatusResponder */ 849 /* Check the special case of certUsageStatusResponder */
848 issuerCert = CERT_FindCertIssuer(cert, t, certUsage); 850 issuerCert = CERT_FindCertIssuer(cert, t, certUsage);
849 if (issuerCert) { 851 if (issuerCert) {
850 if (SEC_CheckCRL(handle, cert, issuerCert, t, wincx) 852 if (SEC_CheckCRL(handle, cert, issuerCert, t, wincx)
851 != SECSuccess) { 853 != SECSuccess) {
852 PORT_SetError(SEC_ERROR_REVOKED_CERTIFICATE); 854 PORT_SetError(SEC_ERROR_REVOKED_CERTIFICATE);
853 CERT_DestroyCertificate(issuerCert); 855 CERT_DestroyCertificate(issuerCert);
854 goto loser; 856 goto loser;
855 } 857 }
856 CERT_DestroyCertificate(issuerCert); 858 CERT_DestroyCertificate(issuerCert);
857 } 859 }
858 /* XXX We have NOT determined that this cert is trusted. 860 /* XXX We have NOT determined that this cert is trusted.
859 * For years, NSS has treated this as trusted, 861 * For years, NSS has treated this as trusted,
860 * but it seems incorrect. 862 * but it seems incorrect.
861 */ 863 */
862 rv = rvFinal; 864 rv = rvFinal;
863 goto done; 865 goto done;
864 } 866 }
865 867
866 /* 868 /*
867 * check the trust params of the issuer 869 * check the trust params of the issuer
868 */ 870 */
869 » flags = SEC_GET_TRUST_FLAGS(cert->trust, trustType); 871 » flags = SEC_GET_TRUST_FLAGS(&certTrust, trustType);
870 if ( ( flags & requiredFlags ) == requiredFlags) { 872 if ( ( flags & requiredFlags ) == requiredFlags) {
871 /* we found a trusted one, so return */ 873 /* we found a trusted one, so return */
872 rv = rvFinal; 874 rv = rvFinal;
873 goto done; 875 goto done;
874 } 876 }
875 if (flags & CERTDB_VALID_CA) { 877 if (flags & CERTDB_VALID_CA) {
876 validCAOverride = PR_TRUE; 878 validCAOverride = PR_TRUE;
877 } 879 }
878 /* is it explicitly distrusted? */ 880 /* is it explicitly distrusted? */
879 if ((flags & CERTDB_TERMINAL_RECORD) && 881 if ((flags & CERTDB_TERMINAL_RECORD) &&
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 * returns success if the cert is not distrusted. If the cert is 953 * returns success if the cert is not distrusted. If the cert is
952 * trusted, then the trusted bool will be true. 954 * trusted, then the trusted bool will be true.
953 * returns failure if the cert is distrusted. If failure, flags 955 * returns failure if the cert is distrusted. If failure, flags
954 * will return the flag bits that indicated distrust. 956 * will return the flag bits that indicated distrust.
955 */ 957 */
956 SECStatus 958 SECStatus
957 cert_CheckLeafTrust(CERTCertificate *cert, SECCertUsage certUsage, 959 cert_CheckLeafTrust(CERTCertificate *cert, SECCertUsage certUsage,
958 unsigned int *failedFlags, PRBool *trusted) 960 unsigned int *failedFlags, PRBool *trusted)
959 { 961 {
960 unsigned int flags; 962 unsigned int flags;
963 CERTCertTrust trust;
961 964
962 *failedFlags = 0; 965 *failedFlags = 0;
963 *trusted = PR_FALSE; 966 *trusted = PR_FALSE;
964 967
965 /* check trust flags to see if this cert is directly trusted */ 968 /* check trust flags to see if this cert is directly trusted */
966 if ( cert->trust ) { 969 if ( CERT_GetCertTrust(cert, &trust) == SECSuccess ) {
967 switch ( certUsage ) { 970 switch ( certUsage ) {
968 case certUsageSSLClient: 971 case certUsageSSLClient:
969 case certUsageSSLServer: 972 case certUsageSSLServer:
970 » flags = cert->trust->sslFlags; 973 » flags = trust.sslFlags;
971 974
972 /* is the cert directly trusted or not trusted ? */ 975 /* is the cert directly trusted or not trusted ? */
973 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is 976 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is
974 * authoritative */ 977 * authoritative */
975 if ( flags & CERTDB_TRUSTED ) { /* trust this cert */ 978 if ( flags & CERTDB_TRUSTED ) { /* trust this cert */
976 *trusted = PR_TRUE; 979 *trusted = PR_TRUE;
977 return SECSuccess; 980 return SECSuccess;
978 } else { /* don't trust this cert */ 981 } else { /* don't trust this cert */
979 *failedFlags = flags; 982 *failedFlags = flags;
980 return SECFailure; 983 return SECFailure;
981 } 984 }
982 } 985 }
983 break; 986 break;
984 case certUsageSSLServerWithStepUp: 987 case certUsageSSLServerWithStepUp:
985 /* XXX - step up certs can't be directly trusted, only distrust */ 988 /* XXX - step up certs can't be directly trusted, only distrust */
986 » flags = cert->trust->sslFlags; 989 » flags = trust.sslFlags;
987 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is 990 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is
988 * authoritative */ 991 * authoritative */
989 if (( flags & CERTDB_TRUSTED ) == 0) { 992 if (( flags & CERTDB_TRUSTED ) == 0) {
990 /* don't trust this cert */ 993 /* don't trust this cert */
991 *failedFlags = flags; 994 *failedFlags = flags;
992 return SECFailure; 995 return SECFailure;
993 } 996 }
994 } 997 }
995 break; 998 break;
996 case certUsageSSLCA: 999 case certUsageSSLCA:
997 » flags = cert->trust->sslFlags; 1000 » flags = trust.sslFlags;
998 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is 1001 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is
999 * authoritative */ 1002 * authoritative */
1000 if (( flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA) ) == 0) { 1003 if (( flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA) ) == 0) {
1001 /* don't trust this cert */ 1004 /* don't trust this cert */
1002 *failedFlags = flags; 1005 *failedFlags = flags;
1003 return SECFailure; 1006 return SECFailure;
1004 } 1007 }
1005 } 1008 }
1006 break; 1009 break;
1007 case certUsageEmailSigner: 1010 case certUsageEmailSigner:
1008 case certUsageEmailRecipient: 1011 case certUsageEmailRecipient:
1009 » flags = cert->trust->emailFlags; 1012 » flags = trust.emailFlags;
1010 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is 1013 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is
1011 * authoritative */ 1014 * authoritative */
1012 if ( flags & CERTDB_TRUSTED ) { /* trust this cert */ 1015 if ( flags & CERTDB_TRUSTED ) { /* trust this cert */
1013 *trusted = PR_TRUE; 1016 *trusted = PR_TRUE;
1014 return SECSuccess; 1017 return SECSuccess;
1015 } 1018 }
1016 else { /* don't trust this cert */ 1019 else { /* don't trust this cert */
1017 *failedFlags = flags; 1020 *failedFlags = flags;
1018 return SECFailure; 1021 return SECFailure;
1019 } 1022 }
1020 } 1023 }
1021 1024
1022 break; 1025 break;
1023 case certUsageObjectSigner: 1026 case certUsageObjectSigner:
1024 » flags = cert->trust->objectSigningFlags; 1027 » flags = trust.objectSigningFlags;
1025 1028
1026 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is 1029 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is
1027 * authoritative */ 1030 * authoritative */
1028 if ( flags & CERTDB_TRUSTED ) { /* trust this cert */ 1031 if ( flags & CERTDB_TRUSTED ) { /* trust this cert */
1029 *trusted = PR_TRUE; 1032 *trusted = PR_TRUE;
1030 return SECSuccess; 1033 return SECSuccess;
1031 } else { /* don't trust this cert */ 1034 } else { /* don't trust this cert */
1032 *failedFlags = flags; 1035 *failedFlags = flags;
1033 return SECFailure; 1036 return SECFailure;
1034 } 1037 }
1035 } 1038 }
1036 break; 1039 break;
1037 case certUsageVerifyCA: 1040 case certUsageVerifyCA:
1038 case certUsageStatusResponder: 1041 case certUsageStatusResponder:
1039 » flags = cert->trust->sslFlags; 1042 » flags = trust.sslFlags;
1040 /* is the cert directly trusted or not trusted ? */ 1043 /* is the cert directly trusted or not trusted ? */
1041 if ( ( flags & ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) == 1044 if ( ( flags & ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) ==
1042 ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) { 1045 ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) {
1043 *trusted = PR_TRUE; 1046 *trusted = PR_TRUE;
1044 return SECSuccess; 1047 return SECSuccess;
1045 } 1048 }
1046 » flags = cert->trust->emailFlags; 1049 » flags = trust.emailFlags;
1047 /* is the cert directly trusted or not trusted ? */ 1050 /* is the cert directly trusted or not trusted ? */
1048 if ( ( flags & ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) == 1051 if ( ( flags & ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) ==
1049 ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) { 1052 ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) {
1050 *trusted = PR_TRUE; 1053 *trusted = PR_TRUE;
1051 return SECSuccess; 1054 return SECSuccess;
1052 } 1055 }
1053 » flags = cert->trust->objectSigningFlags; 1056 » flags = trust.objectSigningFlags;
1054 /* is the cert directly trusted or not trusted ? */ 1057 /* is the cert directly trusted or not trusted ? */
1055 if ( ( flags & ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) == 1058 if ( ( flags & ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) ==
1056 ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) { 1059 ( CERTDB_VALID_CA | CERTDB_TRUSTED_CA ) ) {
1057 *trusted = PR_TRUE; 1060 *trusted = PR_TRUE;
1058 return SECSuccess; 1061 return SECSuccess;
1059 } 1062 }
1060 /* fall through to test distrust */ 1063 /* fall through to test distrust */
1061 case certUsageAnyCA: 1064 case certUsageAnyCA:
1062 case certUsageUserCertImport: 1065 case certUsageUserCertImport:
1063 /* do we distrust these certs explicitly */ 1066 /* do we distrust these certs explicitly */
1064 » flags = cert->trust->sslFlags; 1067 » flags = trust.sslFlags;
1065 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is 1068 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is
1066 * authoritative */ 1069 * authoritative */
1067 if ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0) { 1070 if ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0) {
1068 *failedFlags = flags; 1071 *failedFlags = flags;
1069 return SECFailure; 1072 return SECFailure;
1070 } 1073 }
1071 } 1074 }
1072 » flags = cert->trust->emailFlags; 1075 » flags = trust.emailFlags;
1073 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is 1076 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is
1074 * authoritative */ 1077 * authoritative */
1075 if ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0) { 1078 if ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0) {
1076 *failedFlags = flags; 1079 *failedFlags = flags;
1077 return SECFailure; 1080 return SECFailure;
1078 } 1081 }
1079 } 1082 }
1080 /* fall through */ 1083 /* fall through */
1081 case certUsageProtectedObjectSigner: 1084 case certUsageProtectedObjectSigner:
1082 » flags = cert->trust->objectSigningFlags; 1085 » flags = trust.objectSigningFlags;
1083 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is 1086 if ( flags & CERTDB_TERMINAL_RECORD) { /* the trust record is
1084 * authoritative */ 1087 * authoritative */
1085 if ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0) { 1088 if ((flags & (CERTDB_TRUSTED|CERTDB_TRUSTED_CA)) == 0) {
1086 *failedFlags = flags; 1089 *failedFlags = flags;
1087 return SECFailure; 1090 return SECFailure;
1088 } 1091 }
1089 } 1092 }
1090 break; 1093 break;
1091 } 1094 }
1092 } 1095 }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 * certUsageObjectSigner 1426 * certUsageObjectSigner
1424 */ 1427 */
1425 1428
1426 CERTCertificate * 1429 CERTCertificate *
1427 CERT_FindMatchingCert(CERTCertDBHandle *handle, SECItem *derName, 1430 CERT_FindMatchingCert(CERTCertDBHandle *handle, SECItem *derName,
1428 CERTCertOwner owner, SECCertUsage usage, 1431 CERTCertOwner owner, SECCertUsage usage,
1429 PRBool preferTrusted, int64 validTime, PRBool validOnly) 1432 PRBool preferTrusted, int64 validTime, PRBool validOnly)
1430 { 1433 {
1431 CERTCertList *certList = NULL; 1434 CERTCertList *certList = NULL;
1432 CERTCertificate *cert = NULL; 1435 CERTCertificate *cert = NULL;
1436 CERTCertTrust certTrust;
1433 unsigned int requiredTrustFlags; 1437 unsigned int requiredTrustFlags;
1434 SECTrustType requiredTrustType; 1438 SECTrustType requiredTrustType;
1435 unsigned int flags; 1439 unsigned int flags;
1436 1440
1437 PRBool lookingForCA = PR_FALSE; 1441 PRBool lookingForCA = PR_FALSE;
1438 SECStatus rv; 1442 SECStatus rv;
1439 CERTCertListNode *node; 1443 CERTCertListNode *node;
1440 CERTCertificate *saveUntrustedCA = NULL; 1444 CERTCertificate *saveUntrustedCA = NULL;
1441 1445
1442 /* if preferTrusted is set, must be a CA cert */ 1446 /* if preferTrusted is set, must be a CA cert */
(...skipping 21 matching lines...) Expand all
1464 1468
1465 node = CERT_LIST_HEAD(certList); 1469 node = CERT_LIST_HEAD(certList);
1466 1470
1467 while ( !CERT_LIST_END(node, certList) ) { 1471 while ( !CERT_LIST_END(node, certList) ) {
1468 cert = node->cert; 1472 cert = node->cert;
1469 1473
1470 /* looking for a trusted CA cert */ 1474 /* looking for a trusted CA cert */
1471 if ( ( owner == certOwnerCA ) && preferTrusted && 1475 if ( ( owner == certOwnerCA ) && preferTrusted &&
1472 ( requiredTrustType != trustTypeNone ) ) { 1476 ( requiredTrustType != trustTypeNone ) ) {
1473 1477
1474 » » if ( cert->trust == NULL ) { 1478 » » if ( CERT_GetCertTrust(cert, &certTrust) != SECSuccess ) {
1475 flags = 0; 1479 flags = 0;
1476 } else { 1480 } else {
1477 » » flags = SEC_GET_TRUST_FLAGS(cert->trust, requiredTrustType); 1481 » » flags = SEC_GET_TRUST_FLAGS(&certTrust, requiredTrustType);
1478 } 1482 }
1479 1483
1480 if ( ( flags & requiredTrustFlags ) != requiredTrustFlags ) { 1484 if ( ( flags & requiredTrustFlags ) != requiredTrustFlags ) {
1481 /* cert is not trusted */ 1485 /* cert is not trusted */
1482 /* if this is the first cert to get this far, then save 1486 /* if this is the first cert to get this far, then save
1483 * it, so we can use it if we can't find a trusted one 1487 * it, so we can use it if we can't find a trusted one
1484 */ 1488 */
1485 if ( saveUntrustedCA == NULL ) { 1489 if ( saveUntrustedCA == NULL ) {
1486 saveUntrustedCA = cert; 1490 saveUntrustedCA = cert;
1487 } 1491 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 return chain; 1863 return chain;
1860 } 1864 }
1861 1865
1862 cert = CERT_FindCertIssuer(cert, time, usage); 1866 cert = CERT_FindCertIssuer(cert, time, usage);
1863 } 1867 }
1864 1868
1865 /* return partial chain */ 1869 /* return partial chain */
1866 PORT_SetError(SEC_ERROR_UNKNOWN_ISSUER); 1870 PORT_SetError(SEC_ERROR_UNKNOWN_ISSUER);
1867 return chain; 1871 return chain;
1868 } 1872 }
OLDNEW
« no previous file with comments | « mozilla/security/nss/lib/certhigh/certhigh.c ('k') | mozilla/security/nss/lib/certhigh/certvfypkix.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698