GithubHelp home page GithubHelp logo

isabella232 / cert-downloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sugarcrm/cert-downloader

0.0 0.0 0.0 50 KB

(Apple) SSL Certificate downloader [ADOPT ME!]

License: MIT License

JavaScript 100.00%

cert-downloader's Introduction

cert-downloader Build Status

This is a helper module that allows you to download an SSL certificate, by default that of Apple Inc..

Offered functionality:

  • Download certificate and store locally.
  • Convert certificate to PEM format.
  • Validate a file against the certificate.

More information and links to source code: http://evi-snowm.github.io/cert-downloader/

NOTE OpenSSL or compatible must be installed on your system if you wish to use certificates in the PEM format. Without this tool, only the download function will work.

Install

$ npm install cert-downloader

Usage

var CertDownloader = require('cert-downloader');
var certDl = new CertDownloader();

// download and save in default (cache) location
certDl.cert(function (error, certificatePath) {
    if(error) {
        console.error('Error ' + error);
    } else {
        console.log('Certificate downloaded to ' + certificatePath);
        // /nodeproject/certificate/AppleIncRootCertificate.cer
    }
});

// download and convert to PEM (will use cached cer file and convert that to pem)
certDl.pem(function (error, certificatePath) {
    if(error) {
        console.error('Error ' + error);
    } else {
        console.log('Certificate downloaded to ' + certificatePath);
        // /nodeproject/certificate/AppleIncRootCertificate.pem
    }
});

// verifiy an existing file against the certificate
// (will download and convert if required)
var file = '/nodeproject/certificate/file-to-verify';
certDl.verify(file, function(error, output) {
    if(error){
      return callback('File verification failed: ' + error);
    }
    console.log('Verified output: ' + output);
  });

API

CertDownloader([options])

Construct a new CertDownloader.

You will always need to call this first. options Overrides one or several defaults and should be in JSON format with any of the following options:

  • certName: name of the certificate (default is AppleIncRootCertificate.cer)
  • url : URL to download the certificate from (default is http://www.apple.com/appleca/AppleIncRootCertificate.cer)
  • cache : path to cache location (a.k.a. where to keep the certificates locally, by default this is the operating system's default directory for temp files)

cert(callback)

Retrieve the certificate.

Attempts to download a missing certificate and returns the path to said certificate if available (either cached or downloaded). The callback gets two arguments (err, path), where path is a string to the location of the certificate.

pem(callback)

Retrieve the certificate in PEM format.

Attempts to download and convert a missing certificate and returns the path to said certificate if available (either cached or converted). The callback gets two arguments (err, path), where path is a string to the location of the certificate.

verify(file, callback)

Verifies a file against the certificate.

Attempts to download and convert a missing certificate and returns the content of the file if successfully verified. The callback gets two arguments (err, output), where output is the content of the file if successfully verified.

License

MIT © Patrick Londema

cert-downloader's People

Contributors

evi-snowm avatar vitalymak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.