2
0

do_tests.pl 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. # perl script to run OpenSSL tests
  2. my $base_path = "\\openssl";
  3. my $output_path = "$base_path\\test_out";
  4. my $cert_path = "$base_path\\certs";
  5. my $test_path = "$base_path\\test";
  6. my $app_path = "$base_path\\apps";
  7. my $tmp_cert = "$output_path\\cert.tmp";
  8. my $OpenSSL_config = "$app_path\\openssl.cnf";
  9. my $log_file = "$output_path\\tests.log";
  10. my $pause = 0;
  11. # process the command line args to see if they wanted us to pause
  12. # between executing each command
  13. foreach $i (@ARGV)
  14. {
  15. if ($i =~ /^-p$/)
  16. { $pause=1; }
  17. }
  18. main();
  19. ############################################################################
  20. sub main()
  21. {
  22. # delete all the output files in the output directory
  23. unlink <$output_path\\*.*>;
  24. # open the main log file
  25. open(OUT, ">$log_file") || die "unable to open $log_file\n";
  26. print( OUT "========================================================\n");
  27. my $outFile = "$output_path\\version.out";
  28. system("openssl2 version (CLIB_OPT)/>$outFile");
  29. log_output("CHECKING FOR OPENSSL VERSION:", $outFile);
  30. algorithm_tests();
  31. encryption_tests();
  32. evp_tests();
  33. pem_tests();
  34. verify_tests();
  35. ca_tests();
  36. ssl_tests();
  37. close(OUT);
  38. print("\nCompleted running tests.\n\n");
  39. print("Check log file for errors: $log_file\n");
  40. }
  41. ############################################################################
  42. sub algorithm_tests
  43. {
  44. my $i;
  45. my $outFile;
  46. my @tests = ( rsa_test, destest, ideatest, bftest, bntest, shatest, sha1test,
  47. sha256t, sha512t, dsatest, md2test, md4test, md5test, mdc2test,
  48. rc2test, rc4test, rc5test, randtest, rmdtest, dhtest, ecdhtest,
  49. ecdsatest, ectest, exptest, casttest, hmactest );
  50. print( "\nRUNNING CRYPTO ALGORITHM TESTS:\n\n");
  51. print( OUT "\n========================================================\n");
  52. print( OUT "CRYPTO ALGORITHM TESTS:\n\n");
  53. foreach $i (@tests)
  54. {
  55. if (-e "$base_path\\$i.nlm")
  56. {
  57. $outFile = "$output_path\\$i.out";
  58. system("$i (CLIB_OPT)/>$outFile");
  59. log_desc("Test: $i\.nlm:");
  60. log_output("", $outFile );
  61. }
  62. else
  63. {
  64. log_desc("Test: $i\.nlm: file not found");
  65. }
  66. }
  67. }
  68. ############################################################################
  69. sub encryption_tests
  70. {
  71. my $i;
  72. my $outFile;
  73. my @enc_tests = ( "enc", "rc4", "des-cfb", "des-ede-cfb", "des-ede3-cfb",
  74. "des-ofb", "des-ede-ofb", "des-ede3-ofb",
  75. "des-ecb", "des-ede", "des-ede3", "des-cbc",
  76. "des-ede-cbc", "des-ede3-cbc", "idea-ecb", "idea-cfb",
  77. "idea-ofb", "idea-cbc", "rc2-ecb", "rc2-cfb",
  78. "rc2-ofb", "rc2-cbc", "bf-ecb", "bf-cfb",
  79. "bf-ofb", "bf-cbc" );
  80. my $input = "$base_path\\do_tests.pl";
  81. my $cipher = "$output_path\\cipher.out";
  82. my $clear = "$output_path\\clear.out";
  83. print( "\nRUNNING ENCRYPTION & DECRYPTION TESTS:\n\n");
  84. print( OUT "\n========================================================\n");
  85. print( OUT "FILE ENCRYPTION & DECRYPTION TESTS:\n\n");
  86. foreach $i (@enc_tests)
  87. {
  88. log_desc("Testing: $i");
  89. # do encryption
  90. $outFile = "$output_path\\enc.out";
  91. system("openssl2 $i -e -bufsize 113 -k test -in $input -out $cipher (CLIB_OPT)/>$outFile" );
  92. log_output("Encrypting: $input --> $cipher", $outFile);
  93. # do decryption
  94. $outFile = "$output_path\\dec.out";
  95. system("openssl2 $i -d -bufsize 157 -k test -in $cipher -out $clear (CLIB_OPT)/>$outFile");
  96. log_output("Decrypting: $cipher --> $clear", $outFile);
  97. # compare files
  98. $x = compare_files( $input, $clear, 1);
  99. if ( $x == 0 )
  100. {
  101. print( "\rSUCCESS - files match: $input, $clear\n");
  102. print( OUT "SUCCESS - files match: $input, $clear\n");
  103. }
  104. else
  105. {
  106. print( "\rERROR: files don't match\n");
  107. print( OUT "ERROR: files don't match\n");
  108. }
  109. do_wait();
  110. # Now do the same encryption but use Base64
  111. # do encryption B64
  112. $outFile = "$output_path\\B64enc.out";
  113. system("openssl2 $i -a -e -bufsize 113 -k test -in $input -out $cipher (CLIB_OPT)/>$outFile");
  114. log_output("Encrypting(B64): $cipher --> $clear", $outFile);
  115. # do decryption B64
  116. $outFile = "$output_path\\B64dec.out";
  117. system("openssl2 $i -a -d -bufsize 157 -k test -in $cipher -out $clear (CLIB_OPT)/>$outFile");
  118. log_output("Decrypting(B64): $cipher --> $clear", $outFile);
  119. # compare files
  120. $x = compare_files( $input, $clear, 1);
  121. if ( $x == 0 )
  122. {
  123. print( "\rSUCCESS - files match: $input, $clear\n");
  124. print( OUT "SUCCESS - files match: $input, $clear\n");
  125. }
  126. else
  127. {
  128. print( "\rERROR: files don't match\n");
  129. print( OUT "ERROR: files don't match\n");
  130. }
  131. do_wait();
  132. } # end foreach
  133. # delete the temporary files
  134. unlink($cipher);
  135. unlink($clear);
  136. }
  137. ############################################################################
  138. sub pem_tests
  139. {
  140. my $i;
  141. my $tmp_out;
  142. my $outFile = "$output_path\\pem.out";
  143. my %pem_tests = (
  144. "crl" => "testcrl.pem",
  145. "pkcs7" => "testp7.pem",
  146. "req" => "testreq2.pem",
  147. "rsa" => "testrsa.pem",
  148. "x509" => "testx509.pem",
  149. "x509" => "v3-cert1.pem",
  150. "sess_id" => "testsid.pem" );
  151. print( "\nRUNNING PEM TESTS:\n\n");
  152. print( OUT "\n========================================================\n");
  153. print( OUT "PEM TESTS:\n\n");
  154. foreach $i (keys(%pem_tests))
  155. {
  156. log_desc( "Testing: $i");
  157. my $input = "$test_path\\$pem_tests{$i}";
  158. $tmp_out = "$output_path\\$pem_tests{$i}";
  159. if ($i ne "req" )
  160. {
  161. system("openssl2 $i -in $input -out $tmp_out (CLIB_OPT)/>$outFile");
  162. log_output( "openssl2 $i -in $input -out $tmp_out", $outFile);
  163. }
  164. else
  165. {
  166. system("openssl2 $i -in $input -out $tmp_out -config $OpenSSL_config (CLIB_OPT)/>$outFile");
  167. log_output( "openssl2 $i -in $input -out $tmp_out -config $OpenSSL_config", $outFile );
  168. }
  169. $x = compare_files( $input, $tmp_out);
  170. if ( $x == 0 )
  171. {
  172. print( "\rSUCCESS - files match: $input, $tmp_out\n");
  173. print( OUT "SUCCESS - files match: $input, $tmp_out\n");
  174. }
  175. else
  176. {
  177. print( "\rERROR: files don't match\n");
  178. print( OUT "ERROR: files don't match\n");
  179. }
  180. do_wait();
  181. } # end foreach
  182. }
  183. ############################################################################
  184. sub verify_tests
  185. {
  186. my $i;
  187. my $outFile = "$output_path\\verify.out";
  188. $cert_path =~ s/\\/\//g;
  189. my @cert_files = <$cert_path/*.pem>;
  190. print( "\nRUNNING VERIFY TESTS:\n\n");
  191. print( OUT "\n========================================================\n");
  192. print( OUT "VERIFY TESTS:\n\n");
  193. make_tmp_cert_file();
  194. foreach $i (@cert_files)
  195. {
  196. system("openssl2 verify -CAfile $tmp_cert $i (CLIB_OPT)/>$outFile");
  197. log_desc("Verifying cert: $i");
  198. log_output("openssl2 verify -CAfile $tmp_cert $i", $outFile);
  199. }
  200. }
  201. ############################################################################
  202. sub ssl_tests
  203. {
  204. my $outFile = "$output_path\\ssl_tst.out";
  205. my($CAcert) = "$output_path\\certCA.ss";
  206. my($Ukey) = "$output_path\\keyU.ss";
  207. my($Ucert) = "$output_path\\certU.ss";
  208. my($ssltest)= "ssltest -key $Ukey -cert $Ucert -c_key $Ukey -c_cert $Ucert -CAfile $CAcert";
  209. print( "\nRUNNING SSL TESTS:\n\n");
  210. print( OUT "\n========================================================\n");
  211. print( OUT "SSL TESTS:\n\n");
  212. system("ssltest -ssl2 (CLIB_OPT)/>$outFile");
  213. log_desc("Testing sslv2:");
  214. log_output("ssltest -ssl2", $outFile);
  215. system("$ssltest -ssl2 -server_auth (CLIB_OPT)/>$outFile");
  216. log_desc("Testing sslv2 with server authentication:");
  217. log_output("$ssltest -ssl2 -server_auth", $outFile);
  218. system("$ssltest -ssl2 -client_auth (CLIB_OPT)/>$outFile");
  219. log_desc("Testing sslv2 with client authentication:");
  220. log_output("$ssltest -ssl2 -client_auth", $outFile);
  221. system("$ssltest -ssl2 -server_auth -client_auth (CLIB_OPT)/>$outFile");
  222. log_desc("Testing sslv2 with both client and server authentication:");
  223. log_output("$ssltest -ssl2 -server_auth -client_auth", $outFile);
  224. system("ssltest -ssl3 (CLIB_OPT)/>$outFile");
  225. log_desc("Testing sslv3:");
  226. log_output("ssltest -ssl3", $outFile);
  227. system("$ssltest -ssl3 -server_auth (CLIB_OPT)/>$outFile");
  228. log_desc("Testing sslv3 with server authentication:");
  229. log_output("$ssltest -ssl3 -server_auth", $outFile);
  230. system("$ssltest -ssl3 -client_auth (CLIB_OPT)/>$outFile");
  231. log_desc("Testing sslv3 with client authentication:");
  232. log_output("$ssltest -ssl3 -client_auth", $outFile);
  233. system("$ssltest -ssl3 -server_auth -client_auth (CLIB_OPT)/>$outFile");
  234. log_desc("Testing sslv3 with both client and server authentication:");
  235. log_output("$ssltest -ssl3 -server_auth -client_auth", $outFile);
  236. system("ssltest (CLIB_OPT)/>$outFile");
  237. log_desc("Testing sslv2/sslv3:");
  238. log_output("ssltest", $outFile);
  239. system("$ssltest -server_auth (CLIB_OPT)/>$outFile");
  240. log_desc("Testing sslv2/sslv3 with server authentication:");
  241. log_output("$ssltest -server_auth", $outFile);
  242. system("$ssltest -client_auth (CLIB_OPT)/>$outFile");
  243. log_desc("Testing sslv2/sslv3 with client authentication:");
  244. log_output("$ssltest -client_auth ", $outFile);
  245. system("$ssltest -server_auth -client_auth (CLIB_OPT)/>$outFile");
  246. log_desc("Testing sslv2/sslv3 with both client and server authentication:");
  247. log_output("$ssltest -server_auth -client_auth", $outFile);
  248. system("ssltest -bio_pair -ssl2 (CLIB_OPT)/>$outFile");
  249. log_desc("Testing sslv2 via BIO pair:");
  250. log_output("ssltest -bio_pair -ssl2", $outFile);
  251. system("ssltest -bio_pair -dhe1024dsa -v (CLIB_OPT)/>$outFile");
  252. log_desc("Testing sslv2/sslv3 with 1024 bit DHE via BIO pair:");
  253. log_output("ssltest -bio_pair -dhe1024dsa -v", $outFile);
  254. system("$ssltest -bio_pair -ssl2 -server_auth (CLIB_OPT)/>$outFile");
  255. log_desc("Testing sslv2 with server authentication via BIO pair:");
  256. log_output("$ssltest -bio_pair -ssl2 -server_auth", $outFile);
  257. system("$ssltest -bio_pair -ssl2 -client_auth (CLIB_OPT)/>$outFile");
  258. log_desc("Testing sslv2 with client authentication via BIO pair:");
  259. log_output("$ssltest -bio_pair -ssl2 -client_auth", $outFile);
  260. system("$ssltest -bio_pair -ssl2 -server_auth -client_auth (CLIB_OPT)/>$outFile");
  261. log_desc("Testing sslv2 with both client and server authentication via BIO pair:");
  262. log_output("$ssltest -bio_pair -ssl2 -server_auth -client_auth", $outFile);
  263. system("ssltest -bio_pair -ssl3 (CLIB_OPT)/>$outFile");
  264. log_desc("Testing sslv3 via BIO pair:");
  265. log_output("ssltest -bio_pair -ssl3", $outFile);
  266. system("$ssltest -bio_pair -ssl3 -server_auth (CLIB_OPT)/>$outFile");
  267. log_desc("Testing sslv3 with server authentication via BIO pair:");
  268. log_output("$ssltest -bio_pair -ssl3 -server_auth", $outFile);
  269. system("$ssltest -bio_pair -ssl3 -client_auth (CLIB_OPT)/>$outFile");
  270. log_desc("Testing sslv3 with client authentication via BIO pair:");
  271. log_output("$ssltest -bio_pair -ssl3 -client_auth", $outFile);
  272. system("$ssltest -bio_pair -ssl3 -server_auth -client_auth (CLIB_OPT)/>$outFile");
  273. log_desc("Testing sslv3 with both client and server authentication via BIO pair:");
  274. log_output("$ssltest -bio_pair -ssl3 -server_auth -client_auth", $outFile);
  275. system("ssltest -bio_pair (CLIB_OPT)/>$outFile");
  276. log_desc("Testing sslv2/sslv3 via BIO pair:");
  277. log_output("ssltest -bio_pair", $outFile);
  278. system("$ssltest -bio_pair -server_auth (CLIB_OPT)/>$outFile");
  279. log_desc("Testing sslv2/sslv3 with server authentication via BIO pair:");
  280. log_output("$ssltest -bio_pair -server_auth", $outFile);
  281. system("$ssltest -bio_pair -client_auth (CLIB_OPT)/>$outFile");
  282. log_desc("Testing sslv2/sslv3 with client authentication via BIO pair:");
  283. log_output("$ssltest -bio_pair -client_auth", $outFile);
  284. system("$ssltest -bio_pair -server_auth -client_auth (CLIB_OPT)/>$outFile");
  285. log_desc("Testing sslv2/sslv3 with both client and server authentication via BIO pair:");
  286. log_output("$ssltest -bio_pair -server_auth -client_auth", $outFile);
  287. }
  288. ############################################################################
  289. sub ca_tests
  290. {
  291. my $outFile = "$output_path\\ca_tst.out";
  292. my($CAkey) = "$output_path\\keyCA.ss";
  293. my($CAcert) = "$output_path\\certCA.ss";
  294. my($CAserial) = "$output_path\\certCA.srl";
  295. my($CAreq) = "$output_path\\reqCA.ss";
  296. my($CAreq2) = "$output_path\\req2CA.ss";
  297. my($CAconf) = "$test_path\\CAss.cnf";
  298. my($Uconf) = "$test_path\\Uss.cnf";
  299. my($Ukey) = "$output_path\\keyU.ss";
  300. my($Ureq) = "$output_path\\reqU.ss";
  301. my($Ucert) = "$output_path\\certU.ss";
  302. print( "\nRUNNING CA TESTS:\n\n");
  303. print( OUT "\n========================================================\n");
  304. print( OUT "CA TESTS:\n");
  305. system("openssl2 req -config $CAconf -out $CAreq -keyout $CAkey -new (CLIB_OPT)/>$outFile");
  306. log_desc("Make a certificate request using req:");
  307. log_output("openssl2 req -config $CAconf -out $CAreq -keyout $CAkey -new", $outFile);
  308. system("openssl2 x509 -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey (CLIB_OPT)/>$outFile");
  309. log_desc("Convert the certificate request into a self signed certificate using x509:");
  310. log_output("openssl2 x509 -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey", $outFile);
  311. system("openssl2 x509 -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2 (CLIB_OPT)/>$outFile");
  312. log_desc("Convert a certificate into a certificate request using 'x509':");
  313. log_output("openssl2 x509 -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2", $outFile);
  314. system("openssl2 req -config $OpenSSL_config -verify -in $CAreq -noout (CLIB_OPT)/>$outFile");
  315. log_output("openssl2 req -config $OpenSSL_config -verify -in $CAreq -noout", $outFile);
  316. system("openssl2 req -config $OpenSSL_config -verify -in $CAreq2 -noout (CLIB_OPT)/>$outFile");
  317. log_output( "openssl2 req -config $OpenSSL_config -verify -in $CAreq2 -noout", $outFile);
  318. system("openssl2 verify -CAfile $CAcert $CAcert (CLIB_OPT)/>$outFile");
  319. log_output("openssl2 verify -CAfile $CAcert $CAcert", $outFile);
  320. system("openssl2 req -config $Uconf -out $Ureq -keyout $Ukey -new (CLIB_OPT)/>$outFile");
  321. log_desc("Make another certificate request using req:");
  322. log_output("openssl2 req -config $Uconf -out $Ureq -keyout $Ukey -new", $outFile);
  323. system("openssl2 x509 -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey -CAserial $CAserial (CLIB_OPT)/>$outFile");
  324. log_desc("Sign certificate request with the just created CA via x509:");
  325. log_output("openssl2 x509 -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey -CAserial $CAserial", $outFile);
  326. system("openssl2 verify -CAfile $CAcert $Ucert (CLIB_OPT)/>$outFile");
  327. log_output("openssl2 verify -CAfile $CAcert $Ucert", $outFile);
  328. system("openssl2 x509 -subject -issuer -startdate -enddate -noout -in $Ucert (CLIB_OPT)/>$outFile");
  329. log_desc("Certificate details");
  330. log_output("openssl2 x509 -subject -issuer -startdate -enddate -noout -in $Ucert", $outFile);
  331. print(OUT "--\n");
  332. print(OUT "The generated CA certificate is $CAcert\n");
  333. print(OUT "The generated CA private key is $CAkey\n");
  334. print(OUT "The current CA signing serial number is in $CAserial\n");
  335. print(OUT "The generated user certificate is $Ucert\n");
  336. print(OUT "The generated user private key is $Ukey\n");
  337. print(OUT "--\n");
  338. }
  339. ############################################################################
  340. sub evp_tests
  341. {
  342. my $i = 'evp_test';
  343. print( "\nRUNNING EVP TESTS:\n\n");
  344. print( OUT "\n========================================================\n");
  345. print( OUT "EVP TESTS:\n\n");
  346. if (-e "$base_path\\$i.nlm")
  347. {
  348. my $outFile = "$output_path\\$i.out";
  349. system("$i $test_path\\evptests.txt (CLIB_OPT)/>$outFile");
  350. log_desc("Test: $i\.nlm:");
  351. log_output("", $outFile );
  352. }
  353. else
  354. {
  355. log_desc("Test: $i\.nlm: file not found");
  356. }
  357. }
  358. ############################################################################
  359. sub log_output( $ $ )
  360. {
  361. my( $desc, $file ) = @_;
  362. my($error) = 0;
  363. my($key);
  364. my($msg);
  365. if ($desc)
  366. {
  367. print("\r$desc\n");
  368. print(OUT "$desc\n");
  369. }
  370. # loop waiting for test program to complete
  371. while ( stat($file) == 0)
  372. { print(". "); sleep(1); }
  373. # copy test output to log file
  374. open(IN, "<$file");
  375. while (<IN>)
  376. {
  377. print(OUT $_);
  378. if ( $_ =~ /ERROR/ )
  379. {
  380. $error = 1;
  381. }
  382. }
  383. # close and delete the temporary test output file
  384. close(IN);
  385. unlink($file);
  386. if ( $error == 0 )
  387. {
  388. $msg = "Test Succeeded";
  389. }
  390. else
  391. {
  392. $msg = "Test Failed";
  393. }
  394. print(OUT "$msg\n");
  395. if ($pause)
  396. {
  397. print("$msg - press ENTER to continue...");
  398. $key = getc;
  399. print("\n");
  400. }
  401. # Several of the testing scripts run a loop loading the
  402. # same NLM with different options.
  403. # On slow NetWare machines there appears to be some delay in the
  404. # OS actually unloading the test nlms and the OS complains about.
  405. # the NLM already being loaded. This additional pause is to
  406. # to help provide a little more time for unloading before trying to
  407. # load again.
  408. sleep(1);
  409. }
  410. ############################################################################
  411. sub log_desc( $ )
  412. {
  413. my( $desc ) = @_;
  414. print("\n");
  415. print("$desc\n");
  416. print(OUT "\n");
  417. print(OUT "$desc\n");
  418. print(OUT "======================================\n");
  419. }
  420. ############################################################################
  421. sub compare_files( $ $ $ )
  422. {
  423. my( $file1, $file2, $binary ) = @_;
  424. my( $n1, $n2, $b1, $b2 );
  425. my($ret) = 1;
  426. open(IN0, $file1) || die "\nunable to open $file1\n";
  427. open(IN1, $file2) || die "\nunable to open $file2\n";
  428. if ($binary)
  429. {
  430. binmode IN0;
  431. binmode IN1;
  432. }
  433. for (;;)
  434. {
  435. $n1 = read(IN0, $b1, 512);
  436. $n2 = read(IN1, $b2, 512);
  437. if ($n1 != $n2) {last;}
  438. if ($b1 != $b2) {last;}
  439. if ($n1 == 0)
  440. {
  441. $ret = 0;
  442. last;
  443. }
  444. }
  445. close(IN0);
  446. close(IN1);
  447. return($ret);
  448. }
  449. ############################################################################
  450. sub do_wait()
  451. {
  452. my($key);
  453. if ($pause)
  454. {
  455. print("Press ENTER to continue...");
  456. $key = getc;
  457. print("\n");
  458. }
  459. }
  460. ############################################################################
  461. sub make_tmp_cert_file()
  462. {
  463. my @cert_files = <$cert_path/*.pem>;
  464. # delete the file if it already exists
  465. unlink($tmp_cert);
  466. open( TMP_CERT, ">$tmp_cert") || die "\nunable to open $tmp_cert\n";
  467. print("building temporary cert file\n");
  468. # create a temporary cert file that contains all the certs
  469. foreach $i (@cert_files)
  470. {
  471. open( IN_CERT, $i ) || die "\nunable to open $i\n";
  472. for(;;)
  473. {
  474. $n = sysread(IN_CERT, $data, 1024);
  475. if ($n == 0)
  476. {
  477. close(IN_CERT);
  478. last;
  479. };
  480. syswrite(TMP_CERT, $data, $n);
  481. }
  482. }
  483. close( TMP_CERT );
  484. }