Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stanleyxu2005/c9ab4a61b4ec25ec0cc3db72acfde238 to your computer and use it in GitHub Desktop.
Save stanleyxu2005/c9ab4a61b4ec25ec0cc3db72acfde238 to your computer and use it in GitHub Desktop.
JKS solution for nodejs
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