UNPKG

pkijs

Version:

Public Key Infrastructure (PKI) is the basis of how identity and key management is performed on the web today. PKIjs is a pure JavaScript library implementing the formats that are used in PKI applications. It is built on WebCrypto and aspires to make it p

971 lines (854 loc) 39.4 kB
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>X.509 certificate's complex example</title> <script type="text/javascript" src="org/pkijs/common.js"></script> <script type="text/javascript" src="org/pkijs/asn1.js"></script> <script type="text/javascript" src="org/pkijs/x509_schema.js"></script> <script type="text/javascript" src="org/pkijs/x509_simpl.js"></script> <script type="text/javascript" src="org/pkijs/cms_schema.js"></script> <script type="text/javascript" src="org/pkijs/cms_simpl.js"></script> <script type="text/javascript" src="org/pkijs/ocsp_tsp_schema.js"></script> <script type="text/javascript" src="org/pkijs/ocsp_tsp_simpl.js"></script> <style type="text/css"> body{background:#EFEFEF;font:normal 14px/16px Helvetica, Arial, sans-serif;} .wrapper{ width:600px; margin:50px auto; padding:50px; border:solid 2px #CCC; border-radius:10px; -webkit-border-radius:10px; box-shadow:0 0 12px 3px #CDCDCD; -webkit-box-shadow:0 0 12px 3px #CDCDCD; background:#FFF; } label{ font:bold 16px/20px Helvetica, Arial, sans-serif; margin:0 0 8px; } textarea{ width:500px; border:solid 1px #999; border-radius:5px; -webkit-border-radius:5px; height:340px; font:normal 12px/15px monospace; display:block; margin:0 0 12px; box-shadow:0 0 5px 5px #EFEFEF inset; -webkit-box-shadow:0 0 5px 5px #EFEFEF inset; padding:20px; resize: none; } a{ display:inline-block; padding:5px 15px; background:#ACD0EC; border:solid 1px #4C6181; color:#000; font:normal 14px/16px Helvetica, Arial, sans-serif; } a:hover{ background:#DAEBF8; cursor:pointer; } .header-block { margin-top:30px; font:bold 16px/20px Helvetica, Arial, sans-serif; } .border-block{ border:solid 2px #999; border-radius:5px; -webkit-border-radius:5px; margin:10px 0 0; padding:20px 30px; background:#F0F4FF; } .border-block h2{ margin:0 0 16px; font:bold 22px/24px Helvetica, Arial, sans-serif; } .border-block p{ margin:0 0 12px; } .border-block p .type{ font-weight:bold; display:inline-block; width:176px; } .border-block .two-col{ overflow:hidden; margin:0 0 16px; } .border-block .two-col .subject{ width:180px; font-weight:bold; margin:0 0 12px; float:left; } .border-block .two-col #cert-attributes{ margin:0; padding:0; float:left; list-style:none; } .border-block .two-col #cert-attributes li p{ margin:0; } .border-block .two-col #cert-attributes li p span{ width:40px; display:inline-block; margin:0 0 5px; } .border-block .two-col #cert-exten{ overflow:hidden; padding:0 0 0 17px; margin:0; list-style-type:square; } table { border:solid; border-collapse:collapse; border-color:black; } th { text-align:center; background: #ccc; padding: 5px; border: 1px solid black; } td { padding: 5px; border: 1px solid black; } </style> <script> //********************************************************************************* var certificateBuffer = new ArrayBuffer(0); // ArrayBuffer with loaded or created CERT var trustedCertificates = new Array(); // Array of root certificates from "CA Bundle" var intermadiateCertificates = new Array(); // Array of intermediate certificates var crls = new Array(); // Array of CRLs for all certificates (trusted + intermediate) //********************************************************************************* // #region Auxiliary functions //********************************************************************************* function formatPEM(pem_string) { /// <summary>Format string in order to have each line with length equal to 63</summary> /// <param name="pem_string" type="String">String to format</param> var string_length = pem_string.length; var result_string = ""; for(var i = 0, count = 0; i < string_length; i++, count++) { if(count > 63) { result_string = result_string + "\r\n"; count = 0; } result_string = result_string + pem_string[i]; } return result_string; } //********************************************************************************* function arrayBufferToString(buffer) { /// <summary>Create a string from ArrayBuffer</summary> /// <param name="buffer" type="ArrayBuffer">ArrayBuffer to create a string from</param> var result_string = ""; var view = new Uint8Array(buffer); for(var i = 0; i < view.length; i++) result_string = result_string + String.fromCharCode(view[i]); return result_string; } //********************************************************************************* function stringToArrayBuffer(str) { /// <summary>Create an ArrayBuffer from string</summary> /// <param name="str" type="String">String to create ArrayBuffer from</param> var stringLength = str.length; var resultBuffer = new ArrayBuffer(stringLength); var resultView = new Uint8Array(resultBuffer); for(var i = 0; i < stringLength; i++) resultView[i] = str.charCodeAt(i); return resultBuffer; } //********************************************************************************* function handleFileBrowse(evt) { var temp_reader = new FileReader(); var current_files = evt.target.files; temp_reader.onload = function(event) { certificateBuffer = event.target.result; parse_CERT(); }; temp_reader.readAsArrayBuffer(current_files[0]); } //********************************************************************************* function handleTrustedCertsFile(evt) { var temp_reader = new FileReader(); var current_files = evt.target.files; var current_index = 0; temp_reader.onload = function(event) { try { var asn1 = org.pkijs.fromBER(event.target.result); var cert_simpl = new org.pkijs.simpl.CERT({ schema: asn1.result }); trustedCertificates.push(cert_simpl); } catch(ex) { } }; temp_reader.onloadend = function(event) { if(event.target.readyState === FileReader.DONE) { current_index++; if(current_index < current_files.length) temp_reader.readAsArrayBuffer(current_files[current_index]); } }; temp_reader.readAsArrayBuffer(current_files[0]); } //********************************************************************************* function handleInterCertsFile(evt) { var temp_reader = new FileReader(); var current_files = evt.target.files; var current_index = 0; temp_reader.onload = function(event) { try { var asn1 = org.pkijs.fromBER(event.target.result); var cert_simpl = new org.pkijs.simpl.CERT({ schema: asn1.result }); intermadiateCertificates.push(cert_simpl); } catch(ex) { } }; temp_reader.onloadend = function(event) { if(event.target.readyState === FileReader.DONE) { current_index++; if(current_index < current_files.length) temp_reader.readAsArrayBuffer(current_files[current_index]); } }; temp_reader.readAsArrayBuffer(current_files[0]); } //********************************************************************************* function handleCRLsFile(evt) { var temp_reader = new FileReader(); var current_files = evt.target.files; var current_index = 0; temp_reader.onload = function(event) { try { var asn1 = org.pkijs.fromBER(event.target.result); var crl_simpl = new org.pkijs.simpl.CRL({ schema: asn1.result }); crls.push(crl_simpl); } catch(ex) { } }; temp_reader.onloadend = function(event) { if(event.target.readyState === FileReader.DONE) { current_index++; if(current_index < current_files.length) temp_reader.readAsArrayBuffer(current_files[current_index]); } }; temp_reader.readAsArrayBuffer(current_files[0]); } //********************************************************************************* function handleCABundle(evt) { var temp_reader = new FileReader(); var current_files = evt.target.files; temp_reader.onload = function(event) { parseCAbundle(event.target.result); }; temp_reader.readAsArrayBuffer(current_files[0]); } //********************************************************************************* // #endregion //********************************************************************************* // #region Create CERT //********************************************************************************* function create_CERT(buffer) { // #region Initial variables var sequence = Promise.resolve(); var cert_simpl = new org.pkijs.simpl.CERT(); var cms_signed_simpl; var publicKey; var privateKey; var hash_algorithm = "sha-1"; var hash_algorithm_oid = "1.3.14.3.2.26"; var signature_algorithm = "1.2.840.113549.1.1.5"; var hash_option = document.getElementById("hash_alg").value; switch(hash_option) { case "alg_SHA1": hash_algorithm = "sha-1"; hash_algorithm_oid = "1.3.14.3.2.26"; signature_algorithm = "1.2.840.113549.1.1.5"; break; case "alg_SHA256": hash_algorithm = "sha-256"; hash_algorithm_oid = "2.16.840.1.101.3.4.2.1"; signature_algorithm = "1.2.840.113549.1.1.11"; break; case "alg_SHA384": hash_algorithm = "sha-384"; hash_algorithm_oid = "2.16.840.1.101.3.4.2.2"; signature_algorithm = "1.2.840.113549.1.1.12"; break; case "alg_SHA512": hash_algorithm = "sha-512"; hash_algorithm_oid = "2.16.840.1.101.3.4.2.3"; signature_algorithm = "1.2.840.113549.1.1.13"; break; default:; } // #endregion // #region Get a "crypto" extension var crypto = org.pkijs.getCrypto(); if(typeof crypto == "undefined") { alert("No WebCrypto extension found"); return; } // #endregion // #region Put a static values cert_simpl.version = 2; cert_simpl.serialNumber = new org.pkijs.asn1.INTEGER({ value: 1 }); cert_simpl.issuer.types_and_values.push(new org.pkijs.simpl.ATTR_TYPE_AND_VALUE({ type: "2.5.4.6", // Country name value: new org.pkijs.asn1.PRINTABLESTRING({ value: "RU" }) })); cert_simpl.issuer.types_and_values.push(new org.pkijs.simpl.ATTR_TYPE_AND_VALUE({ type: "2.5.4.3", // Common name value: new org.pkijs.asn1.BMPSTRING({ value: "Test" }) })); cert_simpl.subject.types_and_values.push(new org.pkijs.simpl.ATTR_TYPE_AND_VALUE({ type: "2.5.4.6", // Country name value: new org.pkijs.asn1.PRINTABLESTRING({ value: "RU" }) })); cert_simpl.subject.types_and_values.push(new org.pkijs.simpl.ATTR_TYPE_AND_VALUE({ type: "2.5.4.3", // Common name value: new org.pkijs.asn1.BMPSTRING({ value: "Test" }) })); cert_simpl.notBefore.value = new Date(2013, 01, 01); cert_simpl.notAfter.value = new Date(2016, 01, 01); cert_simpl.extensions = new Array(); // Extensions are not a part of certificate by default, it's an optional array // #region "BasicConstraints" extension //var basic_constr = new org.pkijs.simpl.x509.BasicConstraints({ // cA: true, // pathLenConstraint: 3 //}); //cert_simpl.extensions.push(new org.pkijs.simpl.EXTENSION({ // extnID: "2.5.29.19", // critical: false, // extnValue: basic_constr.toSchema().toBER(false), // parsedValue: basic_constr // Parsed value for well-known extensions //})); // #endregion // #region "KeyUsage" extension var bit_array = new ArrayBuffer(1); var bit_view = new Uint8Array(bit_array); bit_view[0] = bit_view[0] | 0x02; // Key usage "cRLSign" flag //bit_view[0] = bit_view[0] | 0x04; // Key usage "keyCertSign" flag var key_usage = new org.pkijs.asn1.BITSTRING({ value_hex: bit_array }); cert_simpl.extensions.push(new org.pkijs.simpl.EXTENSION({ extnID: "2.5.29.15", critical: false, extnValue: key_usage.toBER(false), parsedValue: key_usage // Parsed value for well-known extensions })); // #endregion cert_simpl.signatureAlgorithm.algorithm_id = signature_algorithm; cert_simpl.signature.algorithm_id = cert_simpl.signatureAlgorithm.algorithm_id; // Must be the same value // #endregion // #region Create a new key pair sequence = sequence.then( function() { return crypto.generateKey({ name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01]), hash: { name: hash_algorithm } }, true, ["sign", "verify"]); } ); // #endregion // #region Store new key in an interim variables sequence = sequence.then( function(keyPair) { publicKey = keyPair.publicKey; privateKey = keyPair.privateKey; }, function(error) { alert("Error during key generation: " + error); } ); // #endregion // #region Exporting public key into "subjectPublicKeyInfo" value of certificate sequence = sequence.then( function() { return cert_simpl.subjectPublicKeyInfo.importKey(publicKey); } ); // #endregion // #region Signing final certificate sequence = sequence.then( function() { return cert_simpl.sign(privateKey); }, function(error) { alert("Error during exporting public key: " + error); } ); // #endregion // #region Encode and store certificate sequence = sequence.then( function() { certificateBuffer = cert_simpl.toSchema(true).toBER(false); var cert_simpl_string = String.fromCharCode.apply(null, new Uint8Array(certificateBuffer)); var result_string = "-----BEGIN CERTIFICATE-----\r\n"; result_string = result_string + formatPEM(window.btoa(cert_simpl_string)); result_string = result_string + "\r\n-----END CERTIFICATE-----\r\n"; document.getElementById("new_signed_data").innerHTML = result_string; parse_CERT(); alert("Certificate created successfully!"); }, function(error) { alert("Error during signing: " + error); } ); // #endregion // #region Exporting private key sequence = sequence.then( function() { return crypto.exportKey("pkcs8", privateKey); } ); // #endregion // #region Store exported key on Web page sequence = sequence.then( function(result) { var private_key_string = String.fromCharCode.apply(null, new Uint8Array(result)); var result_string = document.getElementById("new_signed_data").innerHTML; result_string = result_string + "\r\n-----BEGIN PRIVATE KEY-----\r\n"; result_string = result_string + formatPEM(window.btoa(private_key_string)); result_string = result_string + "\r\n-----END PRIVATE KEY-----\r\n"; document.getElementById("new_signed_data").innerHTML = result_string; alert("Private key exported successfully!"); }, function(error) { alert("Error during exporting of private key: " + error); } ); // #endregion } //********************************************************************************* // #endregion //********************************************************************************* // #region Parse existing CERT //********************************************************************************* function parse_CERT() { // #region Initial check if(certificateBuffer.byteLength === 0) { alert("Nothing to parse!"); return; } // #endregion // #region Initial activities document.getElementById("cert-extn-div").style.display = "none"; var issuerTable = document.getElementById("cert-issuer-table"); while(issuerTable.rows.length > 1) { issuerTable.deleteRow(issuerTable.rows.length - 1); } var subjectTable = document.getElementById("cert-subject-table"); while(subjectTable.rows.length > 1) { subjectTable.deleteRow(subjectTable.rows.length - 1); } var extensionTable = document.getElementById("cert-extn-table"); while(extensionTable.rows.length > 1) { extensionTable.deleteRow(extensionTable.rows.length - 1); } // #endregion // #region Decode existing X.509 certificate var asn1 = org.pkijs.fromBER(certificateBuffer); var cert_simpl = new org.pkijs.simpl.CERT({ schema: asn1.result }); // #endregion // #region Put information about X.509 certificate issuer var rdnmap = { "2.5.4.6": "C", "2.5.4.10": "OU", "2.5.4.11": "O", "2.5.4.3": "CN", "2.5.4.7": "L", "2.5.4.8": "S", "2.5.4.12": "T", "2.5.4.42": "GN", "2.5.4.43": "I", "2.5.4.4": "SN", "1.2.840.113549.1.9.1": "E-mail" }; for(var i = 0; i < cert_simpl.issuer.types_and_values.length; i++) { var typeval = rdnmap[cert_simpl.issuer.types_and_values[i].type]; if(typeof typeval === "undefined") typeval = cert_simpl.issuer.types_and_values[i].type; var subjval = cert_simpl.issuer.types_and_values[i].value.value_block.value; var row = issuerTable.insertRow(issuerTable.rows.length); var cell0 = row.insertCell(0); cell0.innerHTML = typeval; var cell1 = row.insertCell(1); cell1.innerHTML = subjval; } // #endregion // #region Put information about X.509 certificate subject for(var i = 0; i < cert_simpl.subject.types_and_values.length; i++) { var typeval = rdnmap[cert_simpl.subject.types_and_values[i].type]; if(typeof typeval === "undefined") typeval = cert_simpl.subject.types_and_values[i].type; var subjval = cert_simpl.subject.types_and_values[i].value.value_block.value; var row = subjectTable.insertRow(subjectTable.rows.length); var cell0 = row.insertCell(0); cell0.innerHTML = typeval; var cell1 = row.insertCell(1); cell1.innerHTML = subjval; } // #endregion // #region Put information about X.509 certificate serial number document.getElementById("cert-serial-number").innerHTML = org.pkijs.bufferToHexCodes(cert_simpl.serialNumber.value_block.value_hex); // #endregion // #region Put information about issuance date document.getElementById("cert-not-before").innerHTML = cert_simpl.notBefore.value.toString(); // #endregion // #region Put information about expiration date document.getElementById("cert-not-after").innerHTML = cert_simpl.notAfter.value.toString(); // #endregion // #region Put information about subject public key size var publicKeySize = "< unknown >"; if(cert_simpl.subjectPublicKeyInfo.algorithm.algorithm_id.indexOf("1.2.840.113549") !== (-1)) { var asn1_publicKey = org.pkijs.fromBER(cert_simpl.subjectPublicKeyInfo.subjectPublicKey.value_block.value_hex); var rsa_publicKey_simple = new org.pkijs.simpl.x509.RSAPublicKey({ schema: asn1_publicKey.result }); var modulus_view = new Uint8Array(rsa_publicKey_simple.modulus.value_block.value_hex); modulus_bit_length = 0; if(modulus_view[0] === 0x00) modulus_bit_length = (rsa_publicKey_simple.modulus.value_block.value_hex.byteLength - 1) * 8; else modulus_bit_length = rsa_publicKey_simple.modulus.value_block.value_hex.byteLength * 8; publicKeySize = modulus_bit_length.toString(); } document.getElementById("cert-keysize").innerHTML = publicKeySize; // #endregion // #region Put information about signature algorithm var algomap = { "1.2.840.113549.2.1": "MD2", "1.2.840.113549.1.1.2": "MD2 with RSA", "1.2.840.113549.2.5": "MD5", "1.2.840.113549.1.1.4": "MD5 with RSA", "1.3.14.3.2.26": "SHA1", "1.2.840.10040.4.3": "SHA1 with DSA", "1.2.840.10045.4.1": "SHA1 with ECDSA", "1.2.840.113549.1.1.5": "SHA1 with RSA", "2.16.840.1.101.3.4.2.4": "SHA224", "1.2.840.113549.1.1.14": "SHA224 with RSA", "2.16.840.1.101.3.4.2.1": "SHA256", "1.2.840.113549.1.1.11": "SHA256 with RSA", "2.16.840.1.101.3.4.2.2": "SHA384", "1.2.840.113549.1.1.12": "SHA384 with RSA", "2.16.840.1.101.3.4.2.3": "SHA512", "1.2.840.113549.1.1.13": "SHA512 with RSA" }; // array mapping of common algorithm OIDs and corresponding types var signatureAlgorithm = algomap[cert_simpl.signatureAlgorithm.algorithm_id]; if(typeof signatureAlgorithm === "undefined") signatureAlgorithm = cert_simpl.signatureAlgorithm.algorithm_id; else signatureAlgorithm = signatureAlgorithm + " (" + cert_simpl.signatureAlgorithm.algorithm_id + ")"; document.getElementById("cert-sign-algo").innerHTML = signatureAlgorithm; // #endregion // #region Put information about certificate extensions if("extensions" in cert_simpl) { for(var i = 0; i < cert_simpl.extensions.length; i++) { var row = extensionTable.insertRow(extensionTable.rows.length); var cell0 = row.insertCell(0); cell0.innerHTML = cert_simpl.extensions[i].extnID; } document.getElementById("cert-extn-div").style.display = "block"; } // #endregion } //********************************************************************************* // #endregion //********************************************************************************* // #region Verify existing CERT //********************************************************************************* function verify_CERT() { // #region Initial check if(certificateBuffer.byteLength === 0) { alert("Nothing to verify!"); return; } // #endregion // #region Decode existing CERT var asn1 = org.pkijs.fromBER(certificateBuffer); var cert_simpl = new org.pkijs.simpl.CERT({ schema: asn1.result }); // #endregion // #region Create certificate's array (end-user certificate + intermediate certificates) var certs = new Array(); certs.push(cert_simpl); for(var i = 0; i < intermadiateCertificates.length; i++) certs.push(intermadiateCertificates[i]); // #endregion // #region Make a copy of trusted certificates array var trusted_certs = new Array(); for(var j = 0; j < trustedCertificates.length; j++) trusted_certs.push(trustedCertificates[j]); // #endregion // #region Create new X.509 certificate chain object var cert_chain_simpl = new org.pkijs.simpl.CERT_CHAIN({ trusted_certs: trusted_certs, certs: certs, crls: crls }); // #endregion // #region Verify CERT cert_chain_simpl.verify(). then( function(result) { alert("Verification result: " + result.result); }, function(error) { alert("Error during verification: " + error.result_message); } ); // #endregion } //********************************************************************************* // #endregion //********************************************************************************* // #region Parse "CA Bundle" file //********************************************************************************* function parseCAbundle(buffer) { // #region Initial variables var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var startChars = "-----BEGIN CERTIFICATE-----"; var endChars = "-----END CERTIFICATE-----"; var endLineChars = "\r\n"; var view = new Uint8Array(buffer); var waitForStart = false; var middleStage = true; var waitForEnd = false; var waitForEndLine = false; var started = false; var certBodyEncoded = ""; // #endregion for(var i = 0; i < view.length; i++) { if(started === true) { if(base64Chars.indexOf(String.fromCharCode(view[i])) !== (-1)) certBodyEncoded = certBodyEncoded + String.fromCharCode(view[i]); else { if(String.fromCharCode(view[i]) === '-') { // #region Decoded trustedCertificates var asn1 = org.pkijs.fromBER(stringToArrayBuffer(window.atob(certBodyEncoded))); try { trustedCertificates.push(new org.pkijs.simpl.CERT({ schema: asn1.result })); } catch(ex) { alert("Wrong certificate format"); return; } // #endregion // #region Set all "flag variables" certBodyEncoded = ""; started = false; waitForEnd = true; // #endregion } } } else { if(waitForEndLine === true) { if(endLineChars.indexOf(String.fromCharCode(view[i])) === (-1)) { waitForEndLine = false; if(waitForEnd === true) { waitForEnd = false; middleStage = true; } else { if(waitForStart === true) { waitForStart = false; started = true; certBodyEncoded = certBodyEncoded + String.fromCharCode(view[i]); } else middleStage = true; } } } else { if(middleStage === true) { if(String.fromCharCode(view[i]) === "-") { if((i === 0) || ((String.fromCharCode(view[i - 1]) === "\r") || (String.fromCharCode(view[i - 1]) === "\n"))) { middleStage = false; waitForStart = true; } } } else { if(waitForStart === true) { if(startChars.indexOf(String.fromCharCode(view[i])) === (-1)) waitForEndLine = true; } else { if(waitForEnd === true) { if(endChars.indexOf(String.fromCharCode(view[i])) === (-1)) waitForEndLine = true; } } } } } } } //********************************************************************************* // #endregion //********************************************************************************* </script> </head> <body> <div class="wrapper"> <p class="header-block">Create new X.509 certificate</p> <div id="output_div" class="border-block"> <p> <label for="hash_alg" style="font-weight:bold">Hashing algorithm:</label> <select id="hash_alg"> <option value="alg_SHA1">SHA-1</option> <option value="alg_SHA256">SHA-256</option> <option value="alg_SHA384">SHA-384</option> <option value="alg_SHA512">SHA-512</option> </select> </p> <label for="new_signed_data" style="font-weight:bold;float:left;">BASE-64 encoded new certificate + PKCS#8 private key:</label> <textarea id="new_signed_data">&lt; New encoded certificate + PKCS#8 exported private key will be stored here &gt;</textarea> <a onclick="create_CERT();">Create</a> </div> <p class="header-block">Parse loaded/created X.509 certificate</p> <div id="cert-data-block" class="border-block"> <p> <label for="cert-file">Select binary X.509 cert file:</label> <input type="file" id="cert-file" title="X.509 certificate" /> </p> <div id="cert-issuer-div" class="two-col"> <p class="subject">Issuer:</p> <table id="cert-issuer-table"><tr><th>OID</th><th>Value</th></tr></table> </div> <div id="cert-subject-div" class="two-col"> <p class="subject">Subject:</p> <table id="cert-subject-table"><tr><th>OID</th><th>Value</th></tr></table> </div> <p><span class="type">Serial number:</span> <span id="cert-serial-number"></span></p> <p><span class="type">Issuance date:</span> <span id="cert-not-before"></span></p> <p><span class="type">Expiration date:</span> <span id="cert-not-after"></span></p> <p><span class="type">Public key size (bits):</span> <span id="cert-keysize"></span></p> <p><span class="type">Signature algorithm:</span> <span id="cert-sign-algo"></span></p> <div id="cert-extn-div" class="two-col" style="display:none;"> <p class="subject">Extensions:</p> <table id="cert-extn-table"><tr><th>OID</th></tr></table> </div> </div> <p class="header-block">Verify loaded/created X.509 certificate</p> <div id="add-cert-block" class="border-block"> <div class="border-block" style="margin-bottom: 15px;"> <p> <label for="ca_bundle">Load "CA bundle":</label> <input type="file" id="ca_bundle" title="Load CA bundle" /> </p> <p>OR</p> <p> <label for="trusted_certs">Select trusted certs (binary):</label> <input type="file" id="trusted_certs" title="Load trusted certs" multiple="multiple" /> </p> </div> <p> <label for="inter_certs">Load intermediate certificates (binary):</label> <input type="file" id="inter_certs" title="Load interm. certs" multiple="multiple" /> </p> <p> <label for="crls">Load CRLs (binary):</label> <input type="file" id="crls" title="Load CRLs" multiple="multiple" /> </p> <a onclick="verify_CERT();">Verify</a> </div> </div> <script> document.getElementById('cert-file').addEventListener('change', handleFileBrowse, false); document.getElementById('inter_certs').addEventListener('change', handleInterCertsFile, false); document.getElementById('trusted_certs').addEventListener('change', handleTrustedCertsFile, false); document.getElementById('crls').addEventListener('change', handleCRLsFile, false); document.getElementById('ca_bundle').addEventListener('change', handleCABundle, false); </script> </body> </html>