Skip to content

Commit

Permalink
Merge pull request #1236 from hypesystem/document-custom-ca-iss1229
Browse files Browse the repository at this point in the history
Document how to use custom CA in README (#1229)
  • Loading branch information
nylen committed Oct 31, 2014
2 parents f2a44a7 + 7842b17 commit bc733a0
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions README.md
Expand Up @@ -452,12 +452,12 @@ var fs = require('fs')
var options = {
url: 'https://api.some-server.com/',
agentOptions: {
'cert': fs.readFileSync(certFile),
'key': fs.readFileSync(keyFile),
cert: fs.readFileSync(certFile),
key: fs.readFileSync(keyFile),
// Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format:
// 'pfx': fs.readFileSync(pfxFilePath),
'passphrase': 'password',
'securityOptions': 'SSL_OP_NO_SSLv3'
// pfx: fs.readFileSync(pfxFilePath),
passphrase: 'password',
securityOptions: 'SSL_OP_NO_SSLv3'
}
};

Expand All @@ -467,11 +467,23 @@ request.get(options);
It is able to force using SSLv3 only by specifying `secureProtocol`:
```javascript
request.get({
url: 'https://api.some-server.com/',
agentOptions: {
secureProtocol: 'SSLv3_method'
}
});
```
It is possible to accept other certificates than those signed by generally allowed Certificate Authorities (CAs).
This can be useful, for example, when using self-signed certificates.
To allow a different certificate, you can specify the signing CA by adding the contents of the CA's certificate file to the `agentOptions`:
```javascript
request.get({
url: 'https://api.some-server.com/',
agentOptions: {
'secureProtocol': 'SSLv3_method'
ca: fs.readFileSync('ca.cert.pem')
}
});
```
Expand Down

0 comments on commit bc733a0

Please sign in to comment.