Created
May 8, 2025 13:21
-
-
Save stanleyxu2005/c9ab4a61b4ec25ec0cc3db72acfde238 to your computer and use it in GitHub Desktop.
JKS solution for nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jks = require('jks-js'); | |
const keystore = jks.toPem(fs.readFileSync('/path/to/cert1.jks'), 'password'); | |
const { cert, key } = keystore['cert1']; | |
// Create http client | |
const httpsAgent = new https.Agent({ | |
rejectUnauthorized: false, // (NOTE: this will disable client verification) | |
cert: cert, | |
key: key, | |
// passphrase: "YYY" // optional | |
}) | |
const instance = axios.create({ httpsAgent }) | |
// Create server | |
const server = new https.createServer({ cert: cert, key: key }); | |
const wss = new WebSocket.Server({ server }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment