// ------------------------------------------------------------------------------------------
// LacunaWebPKI: Local CAdES Signature
// Signature from local computer file and signed CAdES (P7S) saved in the same directory with suffix '-signed'
var fileInfo = null;
var signedFileInfo = null;
var pki = new LacunaWebPKI('AiEAKi5sYWN1bmFzb2Z0d2FyZS5jb20sanNmaWRkbGUubmV0AAADAFBybwgAABg/D+l74AgAAVP0dSRjd5vjlQ8EFzCfN2tOR/S2ENB6x1vRXssle+wxvbEeT3/vmzm7eKDMWr8kgl2W/BfUqYCOC0PnLOVKS8Em0OXtYD+F3WI1+3zQcvI2W34ppGVx1zizoRfyq+Q4KZ9rZPtFYyoBmr1SR5ZyWPqXWNY7p5XWFkxvFmQU11jho5Cd8VX6cv2OuOEw4eBptN5whzV+9XPHEmPav+TJB0hsYbw0TzwLC253i8WhJEQyIVenNGNNHT3foxsFmDTvXqF/HgjOwqgyJJ1hL0wIqsN0pB5weYhjGLwlRt1FqLV1xTScs5nP3xWTK/CPBpq3NDdTobQMsc7PEF46RT1qXbg=');
function start() {
log('Initializing component');
pki.init({
ready: onWebPkiReady,
defaultFail: onWebPkiError
});
}
function onWebPkiReady() {
refreshCertificates();
}
function onWebPkiError(ex) {
log('Error: ' + ex.userMessage + ' (' + ex.code + ')');
}
// ------------------------------------------
function refreshCertificates() {
log('Listing certificates');
pki.listCertificates({
selectId: 'certificateSelect'
}).success(function(certs) {
log(certs.length + ' certificates found');
});
}
// ------------------------------------------
function signFile() {
// get selected certificate thumbprint
var selectedCertThumb = $('#certificateSelect').val();
if (!selectedCertThumb) {
alert('Select a certificate!');
return;
}
signedFileInfo = null;
log('Signing file...');
pki.signCades({
fileId: fileInfo.id,
output: {
mode: pki.outputModes.autoSave,
fileNameSuffix: '-signed'
},
certificateThumbprint: selectedCertThumb,
includeEncapsulatedContent: true, // includes original file in the P7S
autoDetectCosign: true, // if the file to sign is a P7S, it will perform a...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.