forked from foxylion/docker-nginx-self-signed-https
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget.js
More file actions
executable file
·28 lines (25 loc) · 670 Bytes
/
get.js
File metadata and controls
executable file
·28 lines (25 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
const axios = require('axios');
const https = require('https');
const fs = require('fs');
const path = require('path');
const CERTIFICATES_DIR=__dirname+'/certs/ca/';
const certificates = [];
let axiosCA;
try {
fs.readdirSync(CERTIFICATES_DIR).forEach(function(file) {
if('.crt' === path.extname(file)) {
certificates.push(fs.readFileSync(CERTIFICATES_DIR+file));
}
});
const httpsAgent = new https.Agent({ ca: certificates });
axiosCA = axios.create({ httpsAgent });
} catch(e) {
console.log(e);
axiosCA = axios.create();
}
axiosCA
.get('https://localhost')
.catch(error => {
console.error(error.message);
});