---
title: "Get started"
description: "Get started with Web PKI: check the prerequisites (a certificate in the Windows repository), include the JavaScript library and write the first code."
canonical: "https://docs.lacunasoftware.com/en-us/articles/web-pki/get-started"
locale: "en"
product: "Web PKI"
last_updated: "2026-10-12"
---

# Get started

## Prerequisites

Before you start, you will need a valid digital certificate registered on the Windows certificate repository (this is done automatically when you use a digital certificate in Windows). In order to check if you indeed have a registered digital certificate, follow the steps below:

1. **Start** > **Run...** > **certmgr.msc**
1. There should be at least one certificate under the Personal folder. Double-click it.
1. A window will pop-up with the certificate's information. It should say "You have a private key that corresponds to this certificate"

That's it, you're ready to start.

## Coding the first lines

First, you must include the latest [lacuna-web-pki.js](https://cdn.lacunasoftware.com/libs/web-pki/lacuna-web-pki-2.18.0.min.js) file in your web page:

```html
<script type="text/javascript" src="https://cdn.lacunasoftware.com/libs/web-pki/lacuna-web-pki-2.18.0.min.js"
  integrity="sha256-utM/CTsggW5QWTZgkLcAwVGkMBhYKTz3n0992V4r2y4="
  crossorigin="anonymous"></script>
```

Or install the [NPM web-pki package](https://www.npmjs.com/package/web-pki):

```sh
$ npm install web-pki --save
```

> **Note**
>
> No CSS files have to be included because the component does not interfere in any way in the look and feel of your page.

Next, we'll instantiate the `LacunaWebPKI` class:

```javascript
var pki = new LacunaWebPKI();
```

Then, we'll call the `init()` method to start the component's initialization, passing a callback for when it is ready:

```javascript
pki.init(onWebPkiReady);

function onWebPkiReady() {
    // ...
}
```

Once your callback is invoked, you're ready to go. To retrieve the available certificates, use the `listCertificates()` method:

```javascript
pki.listCertificates().success(function (certs) {
    for (var i = 0; i < certs.length; i++) {
        var cert = certs[i];
        var thumbprint = cert.thumbprint;
        var subjectName = cert.subjectName;
        var issuerName = cert.issuerName;
    }
});
```

> **Note**
>
> If you are not familiar with asynchronous calls, [read this](https://docs.lacunasoftware.com/en-us/articles/web-pki/async).

> **Tip**
>
> To find out which properties are available for each certificate, see article [Certificate properties](https://docs.lacunasoftware.com/en-us/articles/web-pki/cert-properties)

To read a certificate's binary encoding, call the `readCertificate()` method:

```javascript
// You will need the certificate's thumbprint (as returned by the listCertificates method)
var selectedCertThumbprint = '...';
pki.readCertificate({ thumbprint: selectedCertThumbprint }).success(function (certEncoding) {
    // certEncoding contains the certificate's encoding (in Base64)
});
```

In order to sign bytes use the `signData()` method, which receives 3 inputs:

* The certificate's thumbprint
* The bytes to be signed (in Base64 encoding)
* The digest algorithm to be used during the signature operation

```javascript
pki.signData({
    thumbprint: '...',     // as returned by the listCertificates method
    data: '...',           // bytes encoded in Base64 (typically given by server)
    digestAlgorithm: '...' // for instance 'SHA-256' (typically given by server)
}).success(function (signature) {
    // signature contains the result of the signature operation (encoded in Base64)
});
```

If your server-side SDK gives you the digest of the "to-sign-bytes" instead of the actual bytes, you should call the `signHash()` method:

```javascript
pki.signHash({
    thumbprint: '...',     // as returned by the listCertificates method
    hash: '...',           // hash encoded in Base64 (typically given by server)
    digestAlgorithm: '...' // for instance 'SHA-256' (typically given by server)
}).success(function (signature) {
    // signature contains the result of the signature operation (encoded in Base64)
});
```

## Live example

[Embedded content](https://jsfiddle.net/LacunaSoftware/6zkwejb9/embedded/)

In order to run the example, click the **Result** tab. If this is the first time you're using Web PKI, you'll be redirected to the installation page and will be automatically redirected back after the installation completes.

> **Note**
>
> The example above will only work on your web application if it is running on **localhost**. That means you can go ahead and experiment with it in your web application,
> as long as it is running on localhost (i.e. while in development). In order for the code to work outside of localhost (i.e. go into production), you'll need to purchase
> a license. For more information, please see the article [Licensing](https://docs.lacunasoftware.com/en-us/articles/web-pki/licensing).

> **Tip**
>
> The example above targets code simplicity. Please see the [full samples](https://docs.lacunasoftware.com/en-us/articles/web-pki/full-samples) for more real-life code samples.

## Next steps

Now that we've covered the basics ...

* Check the [supported browsers](https://docs.lacunasoftware.com/en-us/articles/web-pki/browser-support)
* See how [licensing](https://docs.lacunasoftware.com/en-us/articles/web-pki/licensing) works
* See how to [customize the behavior when the component is not installed](https://docs.lacunasoftware.com/en-us/articles/web-pki/customizing-not-installed)
* If your application uses AngularJS or Angular2+, read the section [Callbacks and Angular](https://docs.lacunasoftware.com/en-us/articles/web-pki/angularjs)
* Check out the [full samples](https://docs.lacunasoftware.com/en-us/articles/web-pki/full-samples)
* See the [API Reference](https://docs.lacunasoftware.com/en-us/articles/web-pki/api-reference) for detailed information on each method

**Demos and samples**

- Live demo: [Your certificates in the browser](https://try.lacunasoftware.com/en/web-pki/certificates-in-the-browser)
- Live demo: [Sign a file with your certificate](https://try.lacunasoftware.com/en/pki-suite/sign-a-file)
- List the user's certificates with Web PKI: [.NET](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/dotnet/mvc/PkiSuiteAspNetMvcSample/Controllers/ListCertJQueryController.cs) · [Java](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/java/springmvc/src/main/java/com/lacunasoftware/pkisuite/controller/ListCertJQueryController.java) · [Node.js](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/nodejs/expressmvc/routes/list-cert-jquery.js) · [Python](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/python/flask/sample/views/list_cert_jquery.py) · [Ruby](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/ruby/rails/app/controllers/list_cert_jquery_controller.rb)
- Read a certificate's details with Web PKI: [.NET](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/dotnet/mvc/PkiSuiteAspNetMvcSample/Controllers/ReadCertJQueryController.cs) · [Java](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/java/springmvc/src/main/java/com/lacunasoftware/pkisuite/controller/ReadCertJQueryController.java) · [Node.js](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/nodejs/expressmvc/routes/read-cert-jquery.js) · [Python](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/python/flask/sample/views/read_cert_jquery.py) · [Ruby](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/ruby/rails/app/controllers/read_cert_jquery_controller.rb)
- Sign a local PDF in the browser with Web PKI: [.NET](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/dotnet/mvc/PkiSuiteAspNetMvcSample/Controllers/PadesSignatureWebController.cs)
- Sign a local file with CAdES in the browser using Web PKI: [.NET](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/dotnet/mvc/PkiSuiteAspNetMvcSample/Controllers/CadesSignatureWebController.cs)
