npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scep

v0.0.2

Published

Node.js SCEP (Simple Certificate Enrollment Protocol) module

Downloads

4

Readme

A very simple (and incomplete!) implementation of scep protocol for nodejs.

The function that responds to requests must be something like this:

var node_scep = require('scep'); /* With the GET method, the message part is either plain text, or Distinguished Encoding Rules (DER)-encoded PKCS#7 converted to Base64. If the POST method is supported, content that would be sent in Base64 encoding with GET might be sent in binary format with POST instead. */

function pkiclient(req, res){ var operation = req.query && req.query.operation; tlog('pkiclient op=' + operation); /* operation = GetCACert, GetNextCACert, or (optional) GetCACaps: message can be omitted, or can be set to a name that identifies the CA. */

/*
 { operation: 'GetCACert',
 message: 'EnrollmentCAInstance' }
 */
switch(operation){
    case 'GetCACert':
        var crt = ...;// the certificate.pem in der format
        res.setHeader('Content-Type', 'application/x-x509-ca-cert');
        res.setHeader('Content-Length', crt.length);
        res.send(crt);
        break;
/*
 { operation: 'GetCACaps',
 message: 'EnrollmentCAInstance' }
 */

/*
{ operation: 'PKIOperation',
    message: 'MIAG...AAAAAAA=' }
*/
/*
 message is a SCEP pkiMessage structure, based on PKCS#7 and encoded with DER and Base64.
 the pkiMessage structure can be of these types:
 PKCSReq: PKCS#10 CSR
 GetCertInitial: polling for CSR granting status
 GetCert or GetCRL: certificate or CRL retrieval
 */
    case 'PKIOperation':
        var p7sign = new Buffer(req.query.message, 'base64');
        var input = {
            req  : p7sign,
            cert : '/path/of/certificate.pem',
            key  : '/path/of/key.pem'
        };

        var csr = node_scep.extract_csr(input);
        var opt = {
            csr  : csr,
            days : 365,
            caCert : input.cert,
            caKey : input.key,
            outform : 'der'
        };
        //this function call the line command:
        //openssl x509 -req -days 365 -in input.csr -CA cert.pem -CAkey key.pem -CAcreateserial -out out.der -outform der
        openssl.generateCrt(opt, function(err, crt){
            if(err){
                log(err);
                return res.send(500);
            }
            input.crt = crt;//this is a buffer
            var pkcs7 = node_scep.encode_res(input);
            res.setHeader('Content-Type', 'application/x-pki-message');
            res.setHeader('Content-Length', pkcs7.length);
            res.send(pkcs7);
        });
        break;
    default:
        res.send(200);
}

}