Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scep-bb2

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scep-bb2

Node.js SCEP (Simple Certificate Enrollment Protocol) module. Modified to work with latest node.

  • 0.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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);
}

}

Keywords

FAQs

Package last updated on 07 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc