返回> 网站首页
JS数字签名证书安装
yoours2014-10-09 13:18:13
简介一边听听音乐,一边写写文章。
<html>
<head></head>
<body>
<textarea id="sPKCS7" rows="5" cols="50">-----BEGIN CERTIFICATE-----MIIB5DCCAU2gAwIBAgIQzL3lY6cMx6ZNotviuBcmLzANBgkqhkiG9w0BAQQFADAOMQwwCgYDVQQDEwN4eHgwHhc
.................................
Zj07IeO4hv0LZ7UnSTQ4TPZ1QsT42y3Lg=-----END CERTIFICATE-----</textarea>
<object id="XEnroll" classid="clsid:127698e4-e730-4e5c-a2b1-21490a70c8a1" codebase="xenroll.dll"></object>
<script type="text/javascript">
function InstallCerForXP(){
var tinfo = document.getElementById("TxtInfo");
tinfo.innerHTML = "<br>正在安装证书...";
try{
var enroll = document.getElementById('XEnroll');
var cer = document.getElementById('sPKCS7').innerText;
enroll.InstallPKCS7(cer);
tinfo.innerHTML = "<br>证书安装成功!";
}catch(ex){
tinfo.innerHTML = "<br><font color='red'>" + ex.description + "</font>";
return false;
}
return true;
}
</script>
<object id="objCertEnrollClassFactory" classid="clsid:884e2049-217d-11da-b2a4-000e7bbb2b09"></object>
<script type="text/javascript">
function InstallCerForWin7() {
var tinfo = document.getElementById("TxtInfo");
tinfo.innerHTML = "<br>正在安装证书...";
try {
var certEnroll = document.getElementById('objCertEnrollClassFactory');
var objEnroll = certEnroll.CreateObject("X509Enrollment.CX509Enrollment");
var cer = document.getElementById('sPKCS7').innerText;
objEnroll.Initialize(1); // ContextUser
objEnroll.InstallResponse(4, cer, 6, ""); // AllowNone = 0, XCN_CRYPT_STRING_BASE64_ANY = 6
tinfo.innerHTML = "<br>证书安装成功!";
} catch (ex) {
tinfo.innerHTML = "<br><font color='red'>" + ex.description + "</font>";
return false;
}
return true;
}
</script>
<div onclick="InstallCerForXP();">XP</div>
<div onclick="InstallCerForWin7();">Win7</div>
<div></div>
<div id="TxtInfo"></div>
</body>
</html>
文章评论
1957人参与,0条评论