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

📄 gencacert

📁 Perl写的CA认证程序
💻
字号:
## OpenCA - CA Command## (c) 1998-2001 by Massimiliano Pala and OpenCA Group####   File Name: genCACert##       Brief: Generate CA Certificate## Description: Generate the CA's Certificate (self-signed) from the##              request file (careq.pem).##  Parameters: bits, days, passwdmy $cmdName = "genCACert";if ( $cmd !~ /$cmdName/i ) {        configError( "Wrong Command Usage ($cmd over $cmdName)!" );        exit 1;}## This command is executed to generate a new cacert.pem## in the $opencaDir directory. Use the already generated## careq.pemmy $opencaDir = getRequired( 'opencadir' );my $baseDoc   = getRequired( 'gencacertsheet');my $makeCmd   = getRequired( 'MakePath');## Get the parametersmy $bits	= $query->param('bits');my $days	= $query->param('days');my $pwd		= $query->param('passwd');## Other reserved variablesmy $careqFile 	= "$opencaDir/careq.pem";my $cacertFile 	= "$opencaDir/cacert.pem";my $cacertDER	= "$opencaDir/cacert.der";my $cakeyFile 	= "$opencaDir/private/cakey.pem";my ( $page, $crt );configError("Can not find $careqFile!") unless ( -e "$careqFile" );configError("Can not find $cakeyFile!") unless ( -e "$cakeyFile" );## If there is already a cacertfile, than we should move it to .oldif ( -e "$cacertFile" ) {	$tools->moveFiles( SRC=>"$cacertFile",			   DEST=>"$opencaDir/private/cacert_${$}.pem");	$msg = "Old certificate file is (private/cacert_${$}.pem)";}unlink( "$cacertDER" ) if ( -e "$cacertDER" );$cryptoShell->genCert(  KEYFILE=>"$cakeyFile",			REQFILE=>"$careqFile",			OUTFILE=>"$cacertFile",			DAYS=>$days,			PASSWD=>$pwd );configError( "<BR>Error (1) while issuing certificate!<BR>" ) if( $? != 0 );$cryptoShell->dataConvert( DATATYPE=>CERTIFICATE,			   INFILE=>"$cacertFile",			   OUTFILE=>"$cacertDER",			   OUTFORM=>DER );configError( "<BR>Error (2) while convertig certificate<BR>" ) if( $? != 0 );$crt = new OpenCA::X509( SHELL=>$cryptoShell, INFILE=>"$cacertFile" );if( not $crt ) {	configError( "<BR>Error while loading CA certificate" .		     " ($cacertFile)." );} else {	## Let's link to the stuff dir	$tools->copyFiles ( SRC=>"$cacertFile",			    DEST=>"$opencaDir/stuff/cacert.pem");	## Let's link to the chain dir	$tools->copyFiles ( SRC=>"$cacertFile",			    DEST=>"$opencaDir/chain/cacert.crt");	## Let's make the links for chain verification	$ret = `cd ${opencaDir}/chain; $makeCmd`;	if ( not $db->storeItem( DATATYPE=>"VALID_CA_CERTIFICATE",				 OBJECT=>$crt)) {		configError ("Error while storing CA cert to dB!");	}}## If we cannot load the base Document, then errorconfigError("Cannot load $baseDoc.")			 unless ( $page = $query->getFile("$baseDoc"));## Substitute the variables$page = $query->subVar( $page, '$key', $crt->getTXT() );$page = $query->subVar( $page, '$msg', $msg );## Send out the pageprint "$page";1;

⌨️ 快捷键说明

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