📄 test_cert
字号:
## Certificate Testing Script## (c) 1999 by The OpenCA Team## All Rights Reserved#### Project Information:#### Current Version ..................... $ver: 0.020a## Project Started on .................. 17/03/1999## Last Modified on .................... 17/03/1999## Project Closed on ................... n/a#### If you want to contact me (the author) please use the e-mail## addresses listed below. Do not esitate in reporting bugs, enhancement## or anything seems useful in developing this software:#### Miguel Armas <kuko@ulpgc.es>#### Thank you for using this software, and remember that Open Projects## are the future of mankind. Do not sleep, partecipate to world wide## efforts to make life easier for all!## OpenCA - Public Web-Gateway Command## (c) 1998-2001 by Massimiliano Pala and OpenCA Group#### File Name: test_cert## Brief: test a certificate## Description: test and verify an existing certificate which was used ## for loading this page## Parameters: if ( $cmd !~ /test_cert/i ) { configError( "Wrong Command Usage ($cmd/test_cert)!" ); exit 1;} print "Content-type: text/html\n\n"; my $basedoc = getRequired ('testcertform');## my $verifypath = getRequired ('VerifyPath');## my $cacert = getRequired ('CACert');my $cachain = getRequired ('CAChain');if ( $basedoc !~ /\/.*/ ) { $basedoc = "$basedir/$basedoc";}$basedoc = ( glob("$basedir/$basedoc"))[0];# Read query parametersmy $OPERATION = $query->param('operation'); my $signature = $query->param('signature'); my $text = $query->param('text'); ## Get the base Page ( got in $page variable )open ( FD, "$basedoc" ) || die ( "File not Found : $basedoc" ); while( $temp = <FD> ) { $page .= $temp; };close ( FD );$uptime = `date`;chop( $uptime );if ( $OPERATION eq "sign" ) { $table = $query->buildRefs ( ELEMENTS=> ,MAXITEMS=> ); $table = $query->startTable ( COLS=> [ "Variable", "Value" ], WIDTH => "100%", TITLE_BGCOLOR=>"#DDCCFF" ); $table .= $query->addTableLine ( DATA => [ "Text:", "<PRE>$text</PRE>" ] ); $table .= $query->addTableLine ( DATA => [ "Signature:", $signature ] ); # Now write text and signature to temp file (to verify signature) $textfile="/tmp/signtext.$$"; $signaturefile="/tmp/signature.$$"; open(TXT,">$textfile") or die("Can't open $textfile: $!\n"); open(SIGN,">$signaturefile") or die("Can't open $signaturefile: $!\n"); print TXT $text; print SIGN "-----BEGIN PKCS7-----\n"; print SIGN $signature; print SIGN "\n-----END PKCS7-----\n"; close(TXT); close(SIGN); my $sign = new OpenCA::PKCS7( SHELL => $cryptoShell, INFILE => "$signaturefile", DATAFILE => "$textfile", CA_DIR => "$cachain" ); my $info = $sign->verifyChain(); if( $? != 0 ) { $signout = "Couldn't verify the signature"; } else { $signout = "Signature correctly verified"; } unlink $textfile; unlink $signaturefile; $table .= $query->addTableLine ( DATA => [ "Verification:", $signout ] ); # Add relevant Variables... $table .= $query->addTableLine ( DATA => [ "Subject:", $info->{0}->{CN} ] ); $table .= $query->addTableLine ( DATA => [ "E-Mail:", $info->{0}->{EMAIL} ] ); $table .= $query->addTableLine ( DATA => [ "Disinguished Name:", $info->{0}->{DN} ] ); $table .= $query->addTableLine ( DATA => [ "Issued by:", $info->{1}->{DN} ] ); $table .= $query->addTableLine ( DATA => [ "Valid From:", $info->{0}->{NOTBEFORE} ] ); $table .= $query->addTableLine ( DATA => [ "Valid Until:", $info->{0}->{NOTAFTER} ] ); $table .= $query->addTableLine ( DATA => [ "Serial Num.:", $info->{0}->{SERIAL} ] ); ## Close the Table $table .= $query->endTable (); # $table .= "<!--- End of the Cert Test CGI Generated Table ---!>"; $table .= getCopyRight ();} else { $table .= "Sorry there is no data because we have no signed data from you.<br>\n". "Please press sign to give a signature to the server!\n";}# Text to sign$text = "This is some data which you should sign if you want that ". "that the server verify your signature.\n";## Substitute the Variables in the $page$page = $query->subVar( $page, '$uptime', $uptime );$page = $query->subVar( $page, '$table', $table );$page = $query->subVar( $page, '$text', $text );print "$page";exit 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -