LacunaWebPKI: first example
by Lacuna Software
HTML
<script src="https://get.webpkiplugin.com/Scripts/LacunaWebPKI/lacuna-web-pki-2.7.0.js"></script>
<h2>Web PKI - List and read certificate sample</h2>
<select id="certificateSelect"></select>
<button id="refreshCertificates" type="button">Refresh Certificates</button>
<button id="readCertificate" type="button">Read Certificate</button>
<div id="logPanel"></div>
JavaScript
// ------------------------------------------------------------------------------------------
// LacunaWebPKI: List Certificates Sample
var pki = new LacunaWebPKI('ASYAanNmaWRkbGUubmV0LHdlYnBraS5sYWN1bmFzb2Z0d2FyZS5jb20AAAABClKvO1J22vAD+YmfANiKQLbcLE1lNraPKCel6tRM+ZxR+h6M/crtJYRRVGGz7hrdbM0Y0mfTu15RMYGqQMi1QNZS6GrT4vNzIayv552Fl0EFWQA7jWlctUwfYoHRHVEnCNx9YGXDiA9+yDoGlVwgTR7fjzNeS3Fen1MVIyKBF464gN0JvdiCRJMI47JGVDkPmKjcrYIvJs6y5Lg25RW4ZnBKVruS+HR2s3k8ZrV4y4RCQE4UYMKbukF9vsF+JqAEifRlPq2xLcrNdxBveVDSXS/LRHAcrZrMM+Iw4A79jl0ngWPcy+CwinAhT+3dxVo5ZWMRQFpmTkylEMDvTjV9wQ==');
function start() {
log('Initializing component ...');
pki.init({ ready: onWebPkiReady });
}
function onWebPkiReady () {
log('Component ready, listing certificates ...');
refreshCertificates();
}
function refreshCertificates() {
pki.listCertificates({
selectId: 'certificateSelect'
}).success(function (certs) {
log(certs.length + ' certificates found.');
});
}
function readCertificate() {
pki.readCertificate({
thumbprint: $('#certificateSelect').val()
}).success(function (content) {
log('Certificate content: ' + content);
});
}
function log(message) {
$('#logPanel').append('<p>' + message + '</p>');
window.console.log(message);
}
$(function() {
$('#refreshCertificates').click(refreshCertificates);
$('#readCertificate').click(readCertificate);
start();
});