11 #if defined( __MVS__ ) || defined( __VMCMS__ )
13 #pragma convlit( suspend )
15 #if defined( __ILEC400__ )
25 #define EMAILADDR_CERT_NO 14
30 #define CERT_CHAIN_NO 5
48 {
TEXT(
"ldap://ldap.diginotar.nl:389" ),
"ldap.diginotar.nl",
50 TEXT(
"cn=Root Certificaat Productie, o=DigiNotar Root,c=NL" ),
51 TEXT(
"CN=CRL Productie,O=DigiNotar CRL,C=NL" ) },
52 {
TEXT(
"ds.katalog.posten.se" ),
"ds.katalog.posten.se",
53 TEXT(
"cn=Posten CertPolicy_eIDKort_1 CA_nyckel_1, o=Posten_Sverige_AB 556451-4148, c=SE" ),
54 TEXT(
"cn=Posten CertPolicy_eIDKort_1 CA_nyckel_1, o=Posten_Sverige_AB 556451-4148, c=SE" ) },
55 {
TEXT(
"ldap2.zebsign.com" ),
"ldap2.zebsign.com",
56 TEXT(
"pssUniqueIdentifier=24090, CN=First ZebSign Community ID CA, O=ZebSign - 983163432, C=NO" ) }
59 #define LDAP_SERVER_NO 1
60 #define LDAP_ALT_SERVER_NO 2
88 enum { READ_OPTION_NORMAL, READ_OPTION_MULTIPLE };
90 static int checkKeysetCRL(
const CRYPT_KEYSET cryptKeyset,
96 puts(
"Checking certificate against CRL." );
102 return(
extErrorExit( cryptKeyset,
"cryptCheckCert() (for CRL in "
103 "keyset)", status, __LINE__ ) );
115 puts(
" (Certificate has already expired, re-checking in oblivious "
126 return(
extErrorExit( cryptKeyset,
"cryptCheckCert() (for CRL in "
127 "keyset)", status, __LINE__ ) );
133 const C_STR keysetName,
154 printf(
"cryptKeysetOpen() failed with error code %d, line %d.\n",
173 extErrorExit( cryptKeyset,
"cryptGetPublicKey()", status, __LINE__ );
174 puts(
" (404 is a common HTTP error, and non-fatal)." );
178 return(
extErrorExit( cryptKeyset,
"cryptGetPublicKey()", status,
186 printf(
"Expecting certificate object type %d, got %d, line %d.",
187 type, value, __LINE__ );
203 printf( isCertChain ?
"Certificate chain length = %d.\n" : \
204 "CRL has %d entries.\n", value );
212 if( !checkKeysetCRL( cryptKeyset, cryptCert ) )
222 if( option == READ_OPTION_MULTIPLE )
226 for( i = 0; i < 3; i++ )
232 printf(
"cryptGetPublicKey() with cached query failed with "
233 "error code %d, line %d.\n", status, __LINE__ );
244 printf(
"cryptKeysetClose() failed with error code %d, line %d.\n",
253 const C_STR keysetName )
269 printf(
"Couldn't read certificate from file, status %d, line %d.\n",
280 printf(
"Certificate doesn't contain an email address and can't be "
281 "used for testing,\n line %d.\n", __LINE__ );
293 printf(
"Created new certificate database '%s'.\n", keysetName );
308 printf(
"cryptKeysetOpen() failed with error code %d, line %d.\n",
316 puts(
"Adding certificate." );
325 #ifdef UNICODE_STRINGS
332 return(
extErrorExit( cryptKeyset,
"cryptDeleteKey()", status,
338 printExtError( cryptKeyset,
"cryptAddPublicKey()", status, __LINE__ );
358 printf(
"Couldn't read certificate from file, status %d, "
359 "line %d.\n", status, __LINE__ );
372 #ifdef UNICODE_STRINGS
382 return(
extErrorExit( cryptKeyset,
"cryptAddPublicKey()",
383 status, __LINE__ ) );
395 printf(
"cryptCreateCert() failed with error code %d, line %d.\n",
402 return(
attrErrorExit( cryptCert,
"cryptSetAttribute()", status,
419 #ifdef UNICODE_STRINGS
426 return(
extErrorExit( cryptKeyset,
"cryptDeleteKey()", status,
432 return(
extErrorExit( cryptKeyset,
"cryptAddPublicKey()",
433 status, __LINE__ ) );
440 puts(
"Adding CRL." );
444 printf(
"Couldn't read CRL from file, status %d, line %d.\n",
450 return(
extErrorExit( cryptKeyset,
"cryptAddPublicKey()", status,
455 printf(
"Addition of duplicate item to keyset failed to produce "
456 "CRYPT_ERROR_DUPLICATE, status %d, line %d.\n", status,
463 puts(
"Adding certificate chain." );
469 printf(
"Couldn't read certificate chain from file, status %d, "
470 "line %d.\n", status, __LINE__ );
475 return(
extErrorExit( cryptKeyset,
"cryptAddPublicKey()", status,
488 printf(
"Couldn't read user certificate from file, status %d, line "
489 "%d.\n", status, __LINE__ );
494 #ifdef UNICODE_STRINGS
512 return(
extErrorExit( cryptKeyset,
"cryptAddPublicKey()", status,
520 #ifdef UNICODE_STRINGS
523 void *fileNamePtr = filenameBuffer;
528 #ifdef UNICODE_STRINGS
529 mbstowcs( wcBuffer, filenameBuffer, strlen( filenameBuffer ) + 1 );
530 fileNamePtr = wcBuffer;
536 printf(
"Couldn't read user certificate from file, status %d, "
537 "line %d.\n", status, __LINE__ );
542 return(
extErrorExit( cryptKeyset,
"cryptAddPublicKey()", status,
549 #ifdef UNICODE_STRINGS
550 mbstowcs( wcBuffer, filenameBuffer, strlen( filenameBuffer ) + 1 );
551 fileNamePtr = wcBuffer;
557 printf(
"Couldn't read user certificate from file, status %d, "
558 "line %d.\n", status, __LINE__ );
563 return(
extErrorExit( cryptKeyset,
"cryptAddPublicKey()", status,
573 TEXT(
"Mr.Not Appearing in this Keyset" ) );
576 puts(
"Attempt to delete a nonexistant key reports success, the "
577 "database backend glue\ncode needs to be fixed to handle this "
586 printf(
"cryptKeysetClose() failed with error code %d, line %d.\n",
605 printf(
"cryptKeysetOpen() failed with error code %d, line %d.\n",
617 return(
extErrorExit( cryptKeyset,
"Keyset query", status,
633 return(
extErrorExit( cryptKeyset,
"cryptGetPublicKey()", status,
637 puts(
"Only one certificate was returned, this indicates that the "
638 "database backend\nglue code isn't processing ongoing queries "
642 printf(
"%d certificate(s) matched the query.\n", count );
648 printf(
"cryptKeysetClose() failed with error code %d, line %d.\n",
671 printf(
"Couldn't read certificate from file, status %d, line %d.\n",
679 #ifdef UNICODE_STRINGS
690 #ifdef UNICODE_STRINGS
697 for( i = 0; i <
length; i++ )
700 email[ i ] = toupper( email[ i ] );
702 email[ i ] = tolower( email[ i ] );
707 return(
extErrorExit( cryptCert,
"cryptGetAttributeString()", status,
712 puts(
"Testing certificate database read..." );
716 READ_OPTION_NORMAL );
724 puts(
"This is probably because you haven't set up a database or "
725 "data source for use\nas a key database. For this test to "
726 "work, you need to set up a database/data\nsource with the "
732 puts(
"Reading certs using cached query." );
736 READ_OPTION_MULTIPLE );
746 printf(
"Couldn't read certificate chain from file, status %d, "
747 "line %d.\n", status, __LINE__ );
754 #ifdef UNICODE_STRINGS
762 puts(
"Reading complete certificate chain." );
768 puts(
"Certificate database read succeeded.\n" );
776 puts(
"Testing certificate database write..." );
785 printf(
"This may be because you haven't set up a data source "
787 "can be used for the certificate store. You can "
788 "configure\nthe data source type and name using the "
789 "DATABASE_KEYSET_xxx settings in\ntest/test.h.\n",
795 puts(
"Certificate database write succeeded.\n" );
803 puts(
"Testing general certificate database query..." );
812 puts(
"This is probably because you haven't set up a database or "
813 "data source for use\nas a key database. For this test to "
814 "work, you need to set up a database/data\nsource with the "
820 puts(
"Certificate database query succeeded.\n" );
829 static const char FAR_BSS *ldapErrorString = \
830 "LDAP directory read failed, probably because the standard being "
831 "used by the\ndirectory server differs from the one used by the "
832 "LDAP client software (pick\na standard, any standard). If you "
833 "know how the directory being used is\nconfigured, you can try "
834 "changing the CRYPT_OPTION_KEYS_LDAP_xxx settings to\nmatch those "
835 "used by the server. Processing will continue without treating\n"
836 "this as a fatal error.\n";
837 const C_STR ldapKeysetName = ldapUrlInfo[ LDAP_SERVER_NO ].url;
846 puts(
"Testing LDAP directory availability..." );
856 printf(
"%s not available, trying alternative directory...\n",
857 ldapUrlInfo[ LDAP_SERVER_NO ].asciiURL );
858 ldapKeysetName = ldapUrlInfo[ LDAP_ALT_SERVER_NO ].url;
865 printf(
"%s not available either.\n",
866 ldapUrlInfo[ LDAP_ALT_SERVER_NO ].asciiURL );
867 puts(
"None of the test LDAP directories are available. If you need "
868 "to test the\nLDAP capabilities, you need to set up an LDAP "
869 "directory that can be used\nfor the certificate store. You "
870 "can configure the LDAP directory using the\nLDAP_KEYSET_xxx "
871 "settings in test/test.h. Alternatively, if this message\n"
872 "took a long time to appear you may be behind a firewall that "
873 "blocks LDAP\ntraffic.\n" );
878 printf(
"cryptKeysetOpen() failed with error code %d, line %d.\n",
884 ldapAttribute1, &length );
887 #ifdef UNICODE_STRINGS
893 ldapAttribute2, &length );
897 #ifdef UNICODE_STRINGS
903 strcmp( ldapAttribute1, ldapAttribute2 ) )
905 printf(
"Failed to get/set keyset attribute via equivalent global "
906 "attribute, error\ncode %d, value '%s', should be\n'%s', "
907 "line %d.\n", status, ldapAttribute2, ldapAttribute1,
912 printf(
" LDAP directory %s seems to be up, using that for read test.\n",
921 if( !
paramStrcmp( ldapKeysetName, ldapUrlInfo[ LDAP_SERVER_NO ].url ) )
923 puts(
"Testing LDAP certificate read..." );
926 ldapUrlInfo[ LDAP_SERVER_NO ].certName,
928 READ_OPTION_NORMAL );
933 puts( ldapErrorString );
939 puts(
"LDAP certificate read succeeded (CRL read skipped).\n" );
950 puts(
"Testing LDAP CRL read..." );
953 #ifdef UNICODE_STRINGS
958 "certificateRevocationList", 25 );
961 ldapUrlInfo[ LDAP_ALT_SERVER_NO ].crlName,
964 crlName, strlen( crlName ) );
969 puts( ldapErrorString );
973 puts(
"Testing LDAP certificate read..." );
976 #ifdef UNICODE_STRINGS
981 "userCertificate", 15 );
983 caCertName, &length );
984 #ifdef UNICODE_STRINGS
989 "cACertificate", 13 );
992 ldapUrlInfo[ LDAP_ALT_SERVER_NO ].certName,
995 certName, strlen( certName ) );
997 caCertName, strlen( caCertName ) );
1002 puts(
"LDAP directory read failed, probably due to the magic "
1003 "incantatation to fetch\na certificate from this server not "
1004 "matching the one used to fetch a CRL.\nProcessing will "
1005 "continue without treating this as a fatal error.\n" );
1008 puts(
"LDAP certificate/CRL read succeeded.\n" );
1017 puts(
"Testing LDAP directory write..." );
1019 ldapUrlInfo[ LDAP_SERVER_NO ].url );
1027 printf(
"This is probably because you haven't set up an LDAP "
1028 "directory for use as the\nkey store. For this test to "
1029 "work,you need to set up a directory with the\nname "
1030 "'%s'.\n\n", ldapUrlInfo[ LDAP_SERVER_NO ].asciiURL );
1037 puts(
"LDAP directory write failed, probably due to the standard "
1038 "being used by the\ndirectory differing from the one used "
1039 "by cryptlib (pick a standard, any\nstandard). Processing "
1040 "will continue without treating this as a fatal error.\n" );
1043 puts(
"LDAP directory write succeeded.\n" );
1062 puts(
"Testing HTTP certificate read from URL via proxy..." );
1064 "proxy.zetwuinwest.com.pl:80", 27 );
1075 puts(
"Testing HTTP certificate read from URL..." );
1083 puts(
"This is probably because the server isn't available or "
1084 "inaccessible.\n" );
1089 puts(
"If this message took a long time to appear, you may be "
1090 "behind a firewall\nthat blocks HTTP traffic.\n" );
1095 puts(
"Testing HTTP CRL read from URL..." );
1107 puts(
"Testing HTTP mega-CRL read from URL..." );
1117 puts(
"HTTP certificate/CRL read from URL succeeded.\n" );
1127 puts(
"Testing HTTP certificate store read..." );
1135 puts(
"This is probably because the server isn't available or "
1136 "inaccessible.\n" );
1141 puts(
"If this message took a long time to appear, you may be "
1142 "behind a firewall\nthat blocks HTTP traffic.\n" );
1146 puts(
"HTTP certificate store read succeeded.\n" );