Support more platforms
This commit is contained in:
parent
1015b85c2c
commit
6d4b859115
|
@ -0,0 +1,13 @@
|
||||||
|
on: push
|
||||||
|
name: Main Workflow
|
||||||
|
jobs:
|
||||||
|
ubuntu:
|
||||||
|
name: Test on Ubuntu
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
- run: npm install
|
||||||
|
- run: npm test
|
|
@ -16,6 +16,14 @@ certFinder.findCABundle();
|
||||||
// /etc/ssl/certs/ca-certificates.crt
|
// /etc/ssl/certs/ca-certificates.crt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Supported Platforms
|
||||||
|
|
||||||
|
'aix', 'freebsd', 'linux', 'openbsd', 'sunos'
|
||||||
|
|
||||||
|
## Unsupported Platforms
|
||||||
|
|
||||||
|
'ios', 'darwin', 'win32'
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Licensed under the [MIT License](https://nemo.mit-license.org/). See LICENSE file for details.
|
Licensed under the [MIT License](https://nemo.mit-license.org/). See LICENSE file for details.
|
||||||
|
|
4
index.js
4
index.js
|
@ -11,7 +11,7 @@ let accessSyncBool = function(path, mode = fs.constants.R_OK) {
|
||||||
};
|
};
|
||||||
|
|
||||||
let findCABundle = () =>
|
let findCABundle = () =>
|
||||||
PATHS.FILES.find(
|
PATHS[process.platform].files.find(
|
||||||
e =>
|
e =>
|
||||||
fs.existsSync(e) &&
|
fs.existsSync(e) &&
|
||||||
fs.existsSync(fs.realpathSync(e)) &&
|
fs.existsSync(fs.realpathSync(e)) &&
|
||||||
|
@ -20,7 +20,7 @@ let findCABundle = () =>
|
||||||
);
|
);
|
||||||
|
|
||||||
let findCAPath = () =>
|
let findCAPath = () =>
|
||||||
PATHS.DIRECTORIES.find(
|
PATHS[process.platform].directories.find(
|
||||||
e =>
|
e =>
|
||||||
fs.existsSync(e) &&
|
fs.existsSync(e) &&
|
||||||
fs.existsSync(fs.realpathSync(e)) &&
|
fs.existsSync(fs.realpathSync(e)) &&
|
||||||
|
|
94
paths.js
94
paths.js
|
@ -1,44 +1,52 @@
|
||||||
// Based on https://golang.org/src/crypto/x509/root_linux.go
|
|
||||||
|
|
||||||
const FILES = [
|
|
||||||
// Debian/Ubuntu/Gentoo etc.
|
|
||||||
"/etc/ssl/certs/ca-certificates.crt",
|
|
||||||
|
|
||||||
// Fedora/RHEL 6
|
|
||||||
"/etc/pki/tls/certs/ca-bundle.crt",
|
|
||||||
|
|
||||||
// OpenSUSE
|
|
||||||
"/etc/ssl/ca-bundle.pem",
|
|
||||||
|
|
||||||
// OpenELEC
|
|
||||||
"/etc/pki/tls/cacert.pem",
|
|
||||||
|
|
||||||
// CentOS/RHEL 7
|
|
||||||
"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
|
|
||||||
];
|
|
||||||
|
|
||||||
// Based on https://golang.org/src/crypto/x509/root_unix.go
|
|
||||||
const DIRECTORIES = [
|
|
||||||
// SLES10/SLES11, https://golang.org/issue/12139
|
|
||||||
"/etc/ssl/certs",
|
|
||||||
|
|
||||||
// Android
|
|
||||||
"/system/etc/security/cacerts",
|
|
||||||
|
|
||||||
// FreeBSD
|
|
||||||
"/usr/local/share/certs",
|
|
||||||
|
|
||||||
// Fedora/RHEL
|
|
||||||
"/etc/pki/tls/certs",
|
|
||||||
|
|
||||||
// NetBSD
|
|
||||||
"/etc/openssl/certs",
|
|
||||||
|
|
||||||
// AIX
|
|
||||||
"/var/ssl/certs"
|
|
||||||
];
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
FILES: FILES,
|
// https://golang.org/src/crypto/x509/root_aix.go
|
||||||
DIRECTORIES: DIRECTORIES
|
aix: {
|
||||||
};
|
files: ["/var/ssl/certs/ca-bundle.crt"],
|
||||||
|
directories: ["/var/ssl/certs"],
|
||||||
|
},
|
||||||
|
android: {
|
||||||
|
files: [],
|
||||||
|
directories: ["/system/etc/security/cacerts"],
|
||||||
|
},
|
||||||
|
freebsd: {
|
||||||
|
files: [
|
||||||
|
"/usr/local/etc/ssl/cert.pem", // FreeBSD
|
||||||
|
"/usr/local/share/certs/ca-root-nss.crt", // DragonFly
|
||||||
|
"/etc/openssl/certs/ca-certificates.crt", // NetBSD
|
||||||
|
],
|
||||||
|
directories: [
|
||||||
|
"/usr/local/share/certs", // FreeBSD
|
||||||
|
"/etc/openssl/certs", // NetBSD
|
||||||
|
],
|
||||||
|
},
|
||||||
|
linux: {
|
||||||
|
files: [
|
||||||
|
"/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo/Joyent SmartOS etc
|
||||||
|
"/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL 6
|
||||||
|
"/etc/ssl/ca-bundle.pem", // OpenSUSE
|
||||||
|
"/etc/pki/tls/cacert.pem", // OpenELEC
|
||||||
|
"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem", // CentOS/RHEL 7
|
||||||
|
"/etc/ssl/cert.pem", // Alpine Linux
|
||||||
|
],
|
||||||
|
directories: [
|
||||||
|
"/etc/ssl/certs", // SLES10/SLES11, https://golang.org/issue/12139
|
||||||
|
"/etc/pki/tls/certs", // Fedora/RHEL
|
||||||
|
],
|
||||||
|
},
|
||||||
|
openbsd: {
|
||||||
|
files: [
|
||||||
|
"/etc/ssl/cert.pem", // OpenBSD
|
||||||
|
"/usr/local/share/certs/ca-root-nss.crt", // DragonFly
|
||||||
|
"/etc/openssl/certs/ca-certificates.crt", // NetBSD
|
||||||
|
],
|
||||||
|
directories: [],
|
||||||
|
},
|
||||||
|
sunos: {
|
||||||
|
files: [
|
||||||
|
"/etc/certs/ca-certificates.crt", // Solaris 11.2+
|
||||||
|
"/etc/ssl/certs/ca-certificates.crt", // Joyent SmartOS
|
||||||
|
"/etc/ssl/cacert.pem", // OmniOS
|
||||||
|
],
|
||||||
|
directories: ["/etc/certs/CA"],
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in New Issue