11 #if defined( __MVS__ ) || defined( __VMCMS__ )
13 #pragma convlit( suspend )
15 #if defined( __ILEC400__ )
23 const int number,
const BOOLEAN multipleCerts );
30 #if defined( TEST_SESSION ) || defined( TEST_SESSION_LOOPBACK )
42 static int connectCertstoreServer(
void )
46 int connectionActive,
status;
48 puts(
"Testing HTTP certstore server session..." );
57 printf(
"cryptCreateSession() failed with error code %d, line %d.\n",
75 puts(
"SVR: No certificate store available, aborting HTTP certstore "
76 "responder test.\n" );
87 return(
attrErrorExit( cryptSession,
"SVR: cryptSetAttribute()",
96 "certstore server session", status, __LINE__ );
106 printExtError( cryptSession,
"SVR: Persistent connection has been "
107 "closed, operation", status, __LINE__ );
115 printExtError( cryptSession,
"SVR: Attempt to perform second HTTP "
116 "certstore server transaction", status, __LINE__ );
123 printExtError( cryptSession,
"SVR: Attempt to perform third HTTP "
124 "certstore server transaction", status, __LINE__ );
133 printf(
"cryptDestroySession() failed with error code %d, line %d.\n",
138 puts(
"SVR: HTTP certstore server session succeeded.\n" );
142 static int connectCertstoreClient(
void )
161 printf(
"cryptKeysetOpen() failed with error code %d, line %d.\n",
172 return(
extErrorExit( cryptKeyset,
"cryptGetPublicKey()", status,
174 printf(
"Successfully read certificate for '%s'.\n", cert1ID );
181 printf(
"Successfully processed not-present code for '%s'.\n",
184 return(
extErrorExit( cryptKeyset,
"cryptGetPublicKey()", status,
198 return(
extErrorExit( cryptKeyset,
"cryptGetPublicKey()", status,
200 printf(
"Successfully read certificate for '%s'.\n", cert1ID );
210 return( connectCertstoreServer() );
215 #ifdef WINDOWS_THREADS
217 unsigned __stdcall certstoreServerThread(
void *
dummy )
219 connectCertstoreServer();
232 hThread = (
HANDLE ) _beginthreadex( NULL, 0, certstoreServerThread,
233 NULL, 0, &threadID );
237 status = connectCertstoreClient();
256 #define RTCS_SERVER_NO 1
257 #if RTCS_SERVER_NO == 1
258 #define RTCS_SERVER_NAME TEXT( "http://localhost" )
270 #ifdef UNICODE_STRINGS
273 void *fileNamePtr = filenameBuffer;
278 printf(
"%sTesting %sRTCS session...\n", isServer ?
"SVR: " :
"",
279 localSession ?
"local " :
"" );
284 printf(
"Timed out waiting for server to initialise, line %d.\n",
295 printf(
"cryptCreateSession() failed with error code %d, line %d.\n",
309 #ifdef UNICODE_STRINGS
310 mbstowcs( wcBuffer, filenameBuffer, strlen( filenameBuffer ) + 1 );
311 fileNamePtr = wcBuffer;
322 return(
attrErrorExit( cryptSession,
"SVR: cryptSetAttribute()",
323 status, __LINE__ ) );
335 puts(
"SVR: No certificate store available, aborting RTCS "
336 "responder test.\n" );
344 puts(
"SVR: Certificate store hasn't been created yet by "
345 "earlier tests, aborting\n RTCS responder test.\n" );
356 return(
attrErrorExit( cryptSession,
"SVR: cryptSetAttribute()",
357 status, __LINE__ ) );
376 TEXT(
"Test user 1" ) );
381 printf(
"Couldn't read certificate for RTCS status check, error "
382 "code %d, line %d.\n", status, __LINE__ );
387 if( !
initRTCS( &cryptRTCSRequest, cryptCert, localSession ? \
388 1 : RTCS_SERVER_NO, multipleCerts ) )
402 status, __LINE__ ) );
406 #ifdef RTCS_SERVER_NAME
409 printf(
"Setting RTCS server to %s.\n", RTCS_SERVER_NAME );
416 "cryptSetAttributeString()", status,
424 printf(
"Timed out waiting for server to initialise, line %d.\n",
435 "SVR: Attempt to activate RTCS server session" : \
436 "Attempt to activate RTCS client session", status,
446 puts(
" (Server could be down or busy or unavailable, faking it "
447 "and continuing...)\n" );
459 &cryptRTCSResponse );
462 printf(
"cryptGetAttribute() failed with error code %d, line "
463 "%d.\n", status, __LINE__ );
474 printf(
"cryptDestroySession() failed with error code %d, line %d.\n",
479 puts( isServer ?
"SVR: RTCS server session succeeded.\n" : \
480 "RTCS client session succeeded.\n" );
484 static int connectRTCSDirect(
void )
490 printf(
"Testing direct RTCS query...\n" );
497 printf(
"EE cryptImportCert() failed with error code %d, line %d.\n",
507 #ifdef RTCS_SERVER_NAME
512 return(
attrErrorExit( cryptSession,
"cryptSetAttributeString()",
513 status, __LINE__ ) );
518 printf(
"Certificate status check returned %d.\n", status );
524 puts(
"RTCS direct query succeeded.\n" );
532 if( !connectRTCSDirect() )
534 #if RTCS_SERVER_NO == 1
554 #ifdef WINDOWS_THREADS
556 unsigned __stdcall rtcsServerThread(
void *dummy )
572 hThread = (
HANDLE ) _beginthreadex( NULL, 0, rtcsServerThread,
573 NULL, 0, &threadID );
616 #define OCSP_SERVER_NO 5
617 #if OCSP_SERVER_NO == 2
618 #define OCSP_SERVER_NAME TEXT( "http://ocsp.smarttrust.com:82/ocsp" )
619 #elif OCSP_SERVER_NO == 3
620 #define OCSP_SERVER_NAME TEXT( "http://ocsp.xetex.com:8080/servlet/ocsp" )
621 #elif OCSP_SERVER_NO == 4
622 #define OCSP_SERVER_NAME TEXT( "http://ocsp2.valicert.net" )
623 #elif OCSP_SERVER_NO == 5
624 #define OCSP_SERVER_NAME TEXT( "http://ocsp.verisign.com/ocsp/status" )
637 #ifdef UNICODE_STRINGS
640 void *fileNamePtr = filenameBuffer;
645 printf(
"%sTesting %sOCSP session...\n", isServer ?
"SVR: " :
"",
646 localSession ?
"local " :
"" );
651 printf(
"Timed out waiting for server to initialise, line %d.\n",
662 printf(
"cryptCreateSession() failed with error code %d, line %d.\n",
676 #ifdef UNICODE_STRINGS
677 mbstowcs( wcBuffer, filenameBuffer, strlen( filenameBuffer ) + 1 );
678 fileNamePtr = wcBuffer;
689 return(
attrErrorExit( cryptSession,
"SVR: cryptSetAttribute()",
690 status, __LINE__ ) );
702 puts(
"SVR: No certificate store available, aborting OCSP "
703 "responder test.\n" );
714 return(
attrErrorExit( cryptSession,
"SVR: cryptSetAttribute()",
715 status, __LINE__ ) );
724 if( !
initOCSP( &cryptOCSPRequest, localSession ? 1 : OCSP_SERVER_NO,
725 FALSE, revokedCert, multipleCerts,
739 status, __LINE__ ) );
743 #ifdef OCSP_SERVER_NAME
746 printf(
"Setting OCSP server to %s.\n", OCSP_SERVER_NAME );
753 "cryptSetAttributeString()", status,
757 if( OCSP_SERVER_NO == 1 || localSession )
764 status, __LINE__ ) );
770 printf(
"Timed out waiting for server to initialise, line %d.\n",
781 "SVR: Attempt to activate OCSP server session" : \
782 "Attempt to activate OCSP client session", status,
784 #if OCSP_SERVER_NO == 5
787 char errorMessage[ 512 ];
788 int errorMessageLength;
792 errorMessage, &errorMessageLength );
794 !memcmp( errorMessage,
"OCSP response doesn't contain", 29 ) )
797 puts(
" (Verisign's OCSP responder sends broken responses, "
798 "continuing...)\n" );
812 puts(
" (Server could be down or busy or unavailable, faking it "
813 "and continuing...)\n" );
825 &cryptOCSPResponse );
828 printf(
"cryptGetAttribute() failed with error code %d, line "
829 "%d.\n", status, __LINE__ );
845 return(
attrErrorExit( cryptOCSPResponse ,
"cryptCheckCert()",
846 status, __LINE__ ) );
853 printf(
"cryptDestroySession() failed with error code %d, line %d.\n",
858 puts( isServer ?
"SVR: OCSP server session succeeded.\n" : \
859 "OCSP client session succeeded.\n" );
863 static int connectOCSPDirect(
void )
869 printf(
"Testing direct OCSP query...\n" );
876 printf(
"EE cryptImportCert() failed with error code %d, line %d.\n",
886 #ifdef OCSP_SERVER_NAME
891 return(
attrErrorExit( cryptSession,
"cryptSetAttributeString()",
892 status, __LINE__ ) );
901 printf(
"Certificate status check returned %d.\n", status );
907 puts(
"OCSP direct query succeeded.\n" );
915 if( !connectOCSPDirect() )
917 #if OCSP_SERVER_NO == 1
932 #ifdef WINDOWS_THREADS
934 unsigned __stdcall ocspServerThread(
void *dummy )
950 hThread = (
HANDLE ) _beginthreadex( NULL, 0, ocspServerThread,
951 NULL, 0, &threadID );
997 #define TSP_SERVER1_NAME TEXT( "localhost" )
998 #define TSP_SERVER2_NAME TEXT( "http://timestamping.edelweb.fr/service/tsp" )
999 #define TSP_SERVER3_NAME TEXT( "tcp://test.timeproof.de" )
1000 #define TSP_SERVER4_NAME TEXT( "tcp://203.238.37.132:3318" )
1001 #define TSP_SERVER5_NAME TEXT( "tcp://neurath.iaik.at" )
1002 #define TSP_SERVER6_NAME TEXT( "tcp://ricerca.fst.it" )
1003 #define TSP_SERVER7_NAME TEXT( "tcp://tssdemo2.datum.com" )
1004 #define TSP_SERVER8_NAME TEXT( "tcp://ts2.itsc.cuhk.edu.hk:3318" )
1005 #define TSP_SERVER9_NAME TEXT( "tcp://80.81.104.150" )
1006 #define TSP_SERVER10_NAME TEXT( "http://vsinterop.entrust.com:7001/verificationserver/rfc3161timestamp" )
1007 #define TSP_SERVER11_NAME TEXT( "tcp://dse200.ncipher.com" )
1008 #define TSP_SERVER12_NAME TEXT( "http://timestamp.comodoca.com/rfc3161" )
1010 #define TSP_SERVER_NAME TSP_SERVER2_NAME
1011 #define TSP_SERVER_NO 2
1017 const BOOLEAN isRecycledConnection,
1026 printf(
"Timed out waiting for server to initialise, line %d.\n",
1044 if( isRecycledConnection )
1052 printf(
"cryptDeleteAttribute() failed with error code %d, "
1053 "line %d.\n", status, __LINE__ );
1062 printf(
"cryptSetAttribute() failed with error code %d, line "
1063 "%d.\n", status, __LINE__ );
1072 printf(
"Timed out waiting for server to initialise, line %d.\n",
1081 if( localSession && !isRecycledConnection )
1086 #if TSP_SERVER_NO == 11
1095 "SVR: Attempt to activate TSP server session" : \
1096 "Attempt to activate TSP client session", status,
1106 puts(
" (Server could be down, faking it and continuing...)\n" );
1126 "timestamp", status, __LINE__ );
1133 printf(
"cryptPopData() failed with error code %d, line %d.\n",
1137 printf(
"Timestamp data size = %d bytes.\n", bytesCopied );
1138 debugDump(
"tstinfo", buffer, bytesCopied );
1147 const BOOLEAN persistentConnection,
1156 printf(
"%sTesting %sTSP session...\n", isServer ?
"SVR: " :
"",
1157 localSession ?
"local " :
"" );
1160 if( localSession && isServer )
1169 printf(
"%scryptCreateSession() failed with error code %d, line "
1170 "%d.\n", isServer ?
"SVR: " :
"", status, __LINE__ );
1212 printf(
"cryptSetAttribute/cryptSetAttributeString() failed with "
1213 "error code %d, line %d.\n", status, __LINE__ );
1216 status = testTSP( cryptSession, isServer,
FALSE, useAltHash, localSession );
1221 if( persistentConnection )
1223 int connectionActive;
1226 &connectionActive );
1230 "SVR: Persistent connection has been closed, "
1232 "Persistent connection has been closed, operation",
1250 printf(
"cryptDestroySession() failed with error code %d, line %d.\n",
1255 printf( isServer ?
"SVR: %sTSP server session succeeded.\n\n" : \
1256 "%sTSP client session succeeded.\n\n",
1257 persistentConnection ?
"Persistent " :
"" );
1276 #ifdef WINDOWS_THREADS
1278 unsigned __stdcall tspServerThread(
void *dummy )
1294 hThread = (
HANDLE ) _beginthreadex( NULL, 0, tspServerThread,
1295 NULL, 0, &threadID );
1305 unsigned __stdcall tspServerPersistentThread(
void *dummy )
1321 hThread = (
HANDLE ) _beginthreadex( NULL, 0, tspServerPersistentThread,
1322 NULL, 0, &threadID );