Skip to content
nvdbleek edited this page Apr 11, 2013 · 10 revisions

What is about?

This repository will contain a proposal for a X509 Certificate Selector API which is closely integrated with the Web Cryptography API. The prototype will be implemented as a native browser plugin for modern browsers on Mac and Windows. The wiki will contain Use-cases, the API of the proposed API, and examples demonstrating it usage.

The project is still in an early phase and was started to keep the discussion about getting access to smart cards and USB security tokens on the web active.

Sample Usage of API

var crypto = window.crypto;
var selector = crypto.createX509CertificateSelector( { 
                   authorities : [crypto.createX500Principal('CN=eID test Citizen CA, C=BE') ],       
                   privateKeyValid: true
               });

selector.oncomplete = function(e) {
    var certificates = e.target.result;
    if (certificates.length > 0) {
        var certificate = certificates[0];
        var key = certificate.privateKey;
        var cryptoOperation = crypto.encrypt(key.algorithm, key, convertPlainTextToArrayBufferView("Data to sign"));
        cryptoOperation.oncomplete = function(e) {
            console.log("Signature :" + e.target.result);
        }
        
        cryptoOperation.onerror = function(e) {
        	console.log("Error signing data");
        };
        
        cryptoOperation.onabort = function(e) {
        	console.log("Aborted encrypt operation");
        };
    }
}

certificateSelector.onerror = function(e) {
    console.log("Error retrieving certificates");
};
Clone this wiki locally