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

📄 main.scp

📁 Perl写的CA认证程序
💻 SCP
字号:

<!--

// -------------------------------------------------------
// Javascript 0.4.01 - OpenCA Software
//
// Copyright (c) by Massimiliano Pala and OpenCA group
// All rights Reserved
// -------------------------------------------------------

function encode( text ) {

	var ret = "";

	for( i = 0; i < text.length; i++ ) {
		if( text[i] == " " ) {
			ret += "%20";
		} else {
			// ret += text[i];
			ret += text.charAt(i);
		}
	}

	return ret;
}


function viewHelp(type) {

	var helpValue = type;

	if ( type == "init" )
		helpValue = "Help String";

	document.DB.help.value = helpValue;

}

function getPwd( cmd ) {

        var wh = 150;
        var ww = 500;
        var h  = (screen.height-wh)/2;
        var w  = (screen.width-ww)/2;
        var par = "width=" + ww + ",height=" + wh + ",screenx=" +
                                                        w + ",screeny=" + h;
        var msgWindow = window.open("pwd.html", cmd , par);

        msgWindow.focus();

        return false;
}


function getConfirm( message ) {

		if( confirm( message ) != true ) {;
			alert("Aborted!");
			return false;
		}

		return true;
}


function getParams( cmd, theForm ) {

	var message = "";
	var cnf;

	if( cmd == "importCACert" ) {
		message = "This procedure will import an approved CA certificate\n";
		message += "(issued by another CA) using the configured media,\n";
		message += "please check the ca.conf file for arch/de-arch ops.\n\n";
		message += "The certificate should be PEM formatted and named\n";
		message += "'cacert.pem'.\n\n";
		message += "You need to provide a support to proceed (depends\n";
		message += "on configuration). Are you sure you want continue ?\n\n";
		
		// Ask for confirmation
		if( getConfirm( message ) != true ) {
			return false;
		};

		theForm.cmd.value = "importCACert";
		theForm.dataType.value = "VALID_CA_CERTIFICATE";

		theForm.submit();
	}


	if((cmd == "exportCerts") || (cmd == "exportCAReq") || 
						( cmd == "exportCACert") ) {
		message = "You need to provide a support to proceed\n";
		message += "(depends on configuration).\n\n";
		message += "Are you sure you want continue ?\n\n";
		
		// Ask for confirmation
		if( getConfirm( message ) != true ) {
			return false;
		};

		if( cmd == "exportCAReq" ) {
			cmd = "exportCAReqCert";
			theForm.dataType.value = "REQUEST";
		}

		if( cmd == "exportCACert" ) {
			cmd = "exportCAReqCert";
			theForm.dataType.value = "CERTIFICATE";
		}

		theForm.cmd.value = cmd;
		theForm.submit();
	}


	if( cmd == "genSKey" ) {
		var passwd = "";
		var str    = "&" + "pwd=";
		var cont = "true";
		var tmp = "";

		message = "If you cont, you will delete the old\n";
		message += "(if any) CA secret key.\n\n";
		message += "Are you sure you want cont ?\n\n";
		
		// Ask for confirmation
		if( getConfirm( message ) != true ) {
			return false
		};
		
		tmp = prompt("Input encryption algorithm (des,des3,idea)",
								 "des3");

		if((tmp == "") || (tmp == "undefined") || ( tmp == null)) {
				alert("Aborted!");
				return false;
		} else {
			theForm.alg.value = tmp;
		}

		tmp = prompt("Input CA key bits", "2048");
		if((tmp == "") || (tmp == "undefined") || ( tmp == null)) {
			alert("Aborted!");
			return false;
		} else {
			theForm.bits.value = tmp;
		}

		// Set the Right Command
		theForm.cmd.value = cmd;

		// Ask for Password
		getPwd('Password');
	}

	if( cmd == "genCAReq" ) {

		var cont = "true";
		var tmp = "";
		var str = "";

		message = "Now you will be promped with questions about CA\n";
		message += "certificate request to be generated. Optional\n";
		message += "fields can be skipped by simply inserting empty\n";
		message += "values. You can abort at any time the process\n";
		message += "by choosing the 'cancel' button.\n\n";
		message += "Are you sure you want continue ?\n\n";

		// Reset DN value
		theForm.dn.value = "";

		// Ask for confirmation
		if( getConfirm( message ) != true ) {
			return false
		};
		
		tmp = prompt("Input E-mail address, i.e. " + 
			     "camanager@domain.org. (optional)", "");

		if( tmp == null ) {
			alert("Aborted!");
			return false;
		} else {
			theForm.email.value = tmp;
			theForm.dn.value += "Email=" + tmp;
		}

		tmp = prompt("Input Common Name, i.e. " + 
			     "Name Surname. (Optional)", "");

		if( tmp == null ) {
			alert("Aborted!");
			return false;
		} else {
			theForm.cn.value = tmp;
			theForm.dn.value += ", CN=" + tmp;
		}

		tmp = prompt("Input Oragnizational Unit Name, i.e. " +
			     "MyUnit. (Optional)", "");

		if( tmp == null ) {
			alert("Aborted!");
			return false;
		} else {
			theForm.ou.value = tmp;
			theForm.dn.value += ", OU=" + tmp;
		}

		tmp = prompt("Input Oragnization Name (Required - i.e. OpenCA, ... )","");
		if( (tmp == "") || ( tmp == null)) {
			alert("Aborted or Empty value given!");
			return false;
		} else {
			theForm.o.value = tmp;
			theForm.dn.value += ", O=" + tmp;
		}

		tmp = prompt("Country Name (Required - i.e. IT, US, DE, ... )", "");
		if( (tmp == "") || ( tmp == null)) {
			alert("Aborted or Empty value Given!");
			return false;
		} else {
			theForm.c.value = tmp;
			theForm.dn.value += ", C=" + tmp;
		}

		// Set the Right Command
		theForm.cmd.value = cmd;

		// Ask for Password
		getPwd('Password');
	}

	if( cmd == "genCACert" ) {
		var cont = "true";
		var tmp = "";
		var str = "";

		message = "This option let you create a new self signed\n";
		message += "certificate certificate for your CA. You should\n";
		message += "have already generated the the Private Key and\n";
		message += "the CSR. You can abort the process by choosing\n";
		message += "the 'cancel' button.\n\n";
		message += "Are you sure you want continue ?\n\n";

		// Ask for confirmation
		if( getConfirm( message ) != true ) {
			return false
		};
		
		tmp = prompt("CA certificate Validity (in days from now)",
								"730");

		if( (tmp == null) || ( tmp == "") ) {
			alert("Aborted or Empty Value Given!");
			return false;
		} else {
			theForm.days.value = tmp;
		}

		// Set the Right Command
		theForm.cmd.value = cmd;

		// Ask for Password
		getPwd('Password');
	}

	if( cmd == "genCRL" ) {
		var cont = "true";
		var tmp = "";
		var str = "";

		message = "This option let you generate a new CRL, you will\n";
		message += "have to export it with the Export command.\n\n";
		message += "Are you sure you want continue ?\n\n";

		// Ask for confirmation
		if( getConfirm( message ) != true ) {
			return false
		};
		
		// Set the Right Command
		theForm.cmd.value = cmd;

		// Ask for Password
		getPwd('Password');
	}

	if( cmd == "exportCRL" ) {
		var cont = "true";
		var tmp = "";
		var str = "";

		message = "This option let you export newly generated CRL(s)\n";
		message += "to the export device.\n\n";
		message += "Are you sure you want continue ?\n\n";

		// Ask for confirmation
		if( getConfirm( message ) != true ) {
			return false
		};
		
		// Set the Right Command
		theForm.cmd.value = cmd;

		theForm.submit();
	}

	if( cmd == "RemoveDeletedReqs" ) {
		var cont = "true";
		var tmp = "";
		var str = "";

		message = "This option let you delete every deleted request\n";
		message += "actually present in the deleted requests' dB.\n";
		message += "Are you sure you want continue ?\n\n";

		// Ask for confirmation
		if( getConfirm( message ) != true ) {
			return false
		};
		
		// Set the Right Command
		theForm.cmd.value = cmd;
	}
}

//-->

⌨️ 快捷键说明

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