Skip to content

Commit

Permalink
Fixed typos, expanded documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick committed Jun 8, 2015
1 parent fcd09c4 commit fb58723
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# cert-downloader [![Build Status](https://travis-ci.org/evi-snowm/cert-downloader.svg?branch=develop)](https://travis-ci.org/evi-snowm/cert-downloader)

This is a helper module that allows you to dowload an SSL certificate, by default that of Apple Inc..
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/](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.

Expand Down Expand Up @@ -43,7 +45,7 @@ certDl.pem(function (error, certificatePath) {

// verifiy an existing file against the certificate
// (will download and convert if required)
var file = '/nodeproject/certicate/file-to-verify';
var file = '/nodeproject/certificate/file-to-verify';
certDl.verify(file, function(error, output) {
if(error){
return callback('File verification failed: ' + error);
Expand All @@ -52,6 +54,33 @@ certDl.verify(file, function(error, 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
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Inspired by Silas Knobel <[email protected]>
/**
* CertDownloader([options]).
* Construct a new CertDownloader.
*
*
* `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`)
Expand Down Expand Up @@ -56,7 +56,7 @@ function CertDownloader(options) {

/**
* 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
Expand Down Expand Up @@ -84,7 +84,7 @@ CertDownloader.prototype.cert = function (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
Expand Down Expand Up @@ -120,11 +120,11 @@ CertDownloader.prototype.pem = function (callback) {

/**
* Verifies a file against the certificate.
*
*
* Attempts to download and convert a missing certificate and returns the
* content of the file if succesfully verified.
* content of the file if successfully verified.
* The callback gets two arguments (err, output), where output is the content
* of the file if succesfully verified.
* of the file if successfully verified.
*/
CertDownloader.prototype.verify = function (file, callback) {
var _this = this;
Expand All @@ -148,4 +148,4 @@ CertDownloader.prototype.verify = function (file, callback) {
});
};

module.exports = CertDownloader;
module.exports = CertDownloader;

0 comments on commit fb58723

Please sign in to comment.