⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lists

📁 Perl写的CA认证程序
💻
字号:
#!/usr/bin/perl## General List Manager - Version $VER.## (c) 1998 by Massimiliano Pala## All rights Reserved.#### DISC CLAIMER: THIS SOFTWARE IS GIVEN AS IS WITHOUT ANY WARRANTIES## ABOUT ANY DAMAGE DERIVED BY THE USE ( CORRECT OR NOT ) OF THIS## SOFTWARE. THE AUTHOR IS THEREFORE NOT RESPONSABLE IN ANY WAY OF## DAMAGES RELATED IN ANY WAY TO THIS OR SUPPORTED SOFTWARE AS WELL.#### 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:####      madwolf@openca.org#### 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!## Base requirementsrequire 5.001;## Version Information$VER = '0.2.01';$PRG = 'Certificates List Generator';## Add lib/ dir in includes listpush ( @INC, "lib/" );## New OpenCA modulesuse OpenCA::OpenSSL;use OpenCA::X509;use OpenCA::Tools;use OpenCA::DB;use OpenCA::REQ;## Uses the OpenCA::Configuration module by Massimiliano Pala## to load the configuration fileuse OpenCA::Configuration;use OpenCA::TRIStateCGI;## Functions Requirements## ======================require "misc-utils.lib";## Build a Configuration Objectlocal $config = new OpenCA::Configuration;## Define the Configuration Namelocal $CONFIG = 'conf/public.conf';## Load the Configuration file (read and parse)if( $config->loadCfg( $CONFIG ) == undef ) {        print "Content-type: text/html\n\n";        configError( "Unable to load configuration file (request.cnf)!");}## Now it's time to get the parameters passed over the weblocal $query  = new OpenCA::TRIStateCGI;## Flush the Output stream$|=1;print "Content-type: text/html\n\n";## Let's get the base Directorylocal ( $basedir ) = ( $ENV{'SCRIPT_FILENAME'} =~ /(.*)\/.*/ );local $self = $query->url(-query=>0,-full=>0);## Init Section## ============local $shellPath = getRequired( 'openssl' );local $tmpdir    = getRequired( 'TempDir' );local $dbDir     = getRequired( 'dbDir' );local $sslcnf    = getRequired( 'sslconfig' );local $verify    = getRequired( 'VerifyPath' );local $sign      = getRequired( 'SignPath' );local $cryptoShell = new OpenCA::OpenSSL( SHELL=>$shellPath );$cryptoShell->setParams( CONFIG=>"$sslcnf",                         TMPDIR=>"$tmpdir",                         VERIFY=>"$verify",                         SIGN  =>"$sign", );if ( not $cryptoShell ) {        configError( "Cannot initialize Crypto Shell ($shellPath)!" );        exit 1;}local $tools = new OpenCA::Tools();if ( not $tools ) {        configError( "Cannot initialize OpenCA::Tools class!" );        exit 1;}local $db = new OpenCA::DB( SHELL=>$cryptoShell, DB_DIR=>"$dbDir" );if ( not $db ) {        configError( "Cannot initialize OpenCA::DB class! ($dbDir)" );        exit 1;}## Main Section## ============local $cmd = $query->param('cmd');if ( "$cmd" eq "" ) {        configError("Command Error (Command Missing)");        exit 101;}## Variables Definitionmy $getID_url = '/cgi-bin/getID?type=email';my $from    = ( $query->param( 'viewFrom' ) or 0 );my $matched = $query->param( 'rows' );## Set the column titlesmy ( $dbItem, $listType, @list, @cols, $newCMD );## Differentiate the list parametersif( $cmd =~ /^certsList/i) {	$dataType  = 'VALID_CERTIFICATE';	$listType  = '<FONT COLOR="#FF7000">V</FONT>alid ';	$listType .= '<FONT COLOR="#FF7000">C</FONT>ertificates';	$newCMD    = $getID_url;	push( @cols, "Serial" );	push( @cols, "Common Name" );	push( @cols, "Issued on" );	push( @cols, "E-Mail" );} elsif( $cmd =~ /^pendingReqs/i) {	$dataType  = 'PENDING_REQUEST';	$listType  = '<FONT COLOR="#FF7000">P</FONT>ending ';	$listType .= '<FONT COLOR="#FF7000">R</FONT>equests';	push( @cols, "Serial" );	push( @cols, "Requested By" );	push( @cols, "Requested on" );} elsif ( $cmd =~ /^revokedList/i ) {	$dataType  = 'REVOKED_CERTIFICATE';	$listType  = '<FONT COLOR="#FF7000">R</FONT>evoked ';	$listType .= '<FONT COLOR="#FF7000">C</FONT>ertificates';	push( @cols, "Serial" );	push( @cols, "Common Name" );	push( @cols, "Revoked On" );	push( @cols, "E-Mail" );} elsif ( $cmd =~ /^revokedList/i ) {	$dataType  = 'RENEW_CERTIFICATE';	$listType  = '<FONT COLOR="#FF7000">R</FONT>evoked ';	$listType .= '<FONT COLOR="#FF7000">C</FONT>ertificates';	push( @cols, "Serial" );	push( @cols, "Common Name" );	push( @cols, "Revoked On" );	push( @cols, "E-Mail" );} else {	configError("Requested List NOT available");}## Get required parameters ( return only the value string )my $sheet    	= getRequired( 'PendingList' );my $maxItems 	= getRequired( "maxReturnedItems" );## Get the base Page ( got in $page variable )my $page 	= $query->getFile( "$sheet" );my $uptime 	= $tools->getDate();configError ( "Error loading Page $sheet" ) if ( not $page);if ( not $matched ) {	$matched  = $db->elements( DATATYPE=>$dataType );};@list = $db->listItems( DATATYPE=>$dataType, FROM=>$from, ITEMS=>$maxItems );$table  = $query->buildRefs( ELEMENTS=>$matched, ITEMS=>$maxItems  );$table .= $query->startTable( COLS=>[ @cols ],                              WIDTH=>"100%",                              TITLE_BGCOLOR=>"#DDCCFF" );## Process all Filesforeach $dbItem ( @list ) {	## Common Variables	my ( $format, $key, $serial, $ser_col, $op_col, $email, $email_col );	my ( $lnk, $parsed, $head );        my @vals;	$parsed = $dbItem->getParsed();	$head	= $parsed->{HEADER};        $key    = $parsed->{DBKEY};        $serial = ($parsed->{SERIAL} or $head->{SERIAL} or "n/a" );        $notBefore = ( $parsed->{NOTBEFORE} or $head->{NOTBEFORE});	if( $dataType =~ /VALID_CERTIFICATE/i ) {        	$ser_col = "<a href=\"$newCMD&dataType=$dataType" .                		"&key=$key\">". $serial ."</a>";	} else {		$ser_col = $serial;	}        if( (not $head->{OPERATOR}) or ($head->{OPERATOR} eq "n/a") ) {                $op_col = "n/a";        } else {                my $tmpOp = $head->{OPERATOR};                $op_col = "<a href=\"$self?cmd=searchCert&dataType=" .                          "CERTIFICATE&key=$tmpOp\">" .                           $tmpOp ."</a>";        }	push( @vals, $ser_col );        push( @vals, ( $parsed->{CN} or "n/a" ) );        push( @vals, ( $notBefore or "n/a" ) );	if( $dataType =~ /CERTIFICATE/ ) {		if( $parsed->{EMAIL} ) {			$email = ( $parsed->{EMAIL} or "n/a" );			$lnk = new CGI({				subject=>"Certificate Serial $serial"});			$email_col = $lnk->a({-href=>"mailto:$email"},							$email );		} else {			$email_col = "<CENTER>---</CENTER>";		};        	push( @vals, $email_col );	}        $table .= $query->addTableLine( DATA =>[ @vals ]);}## Close the Table$table .= $query->endTable();$table .= getCopyRight();## Substitute the Variables in the $page$page = $query->subVar( $page, '@UPTIME@', $uptime );$page = $query->subVar( $page, '@TABLE@', $table );$page = $query->subVar( $page, '@LISTTYPE@', $listType );print "$page";exit 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -