Nodejs clientCertEngine











up vote
2
down vote

favorite
1












Node.js Version: 11.2.0



OS: debian



Scope (install, code, runtime, meta, other?): issue with 'no client cert method' in tls handshake



Module (and version) (if relevant): openssl node tls clientCertEngine



Having issues with this trying to use a Hardware Security Module which stores the private key. (non readable/non exportable)



Without the HSM, there are no issues. Maybe I am calling clientCertEngine incorrectly? Or is there issue not allowing us to enter -keyform e?



although using s_client works as follows:



openssl s_client -host myHost.com -port 3000 -key fake.key -cert device.crt -CAfile ca.crt -engine hsm_engine -keyform e


When running client node tls connect:



_tls_common.js:204 c.context.setClientCertEngine(options.clientCertEngine);

Error: error:1412214B:SSL routines:SSL_CTX_set_client_cert_engine:no client cert method
at Object.createSecureContext (_tls_common.js:204:17)
at Object.connect (_tls_wrap.js:1205:48)
at Object. (/home/pi/test/tls.js:20:19)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
at startup (internal/bootstrap/node.js:300:19)


And the js code



const tls = require('tls');
const fs = require('fs');
const options = { // key: null //cannot be exported nor read. Ive tried with both null and removed key entirely
cert: fs.readFileSync('client.crt'),
clientCertEngine: '/path/to/hsm/.so file',
ca: [fs.readFileSync('ca.crt')], };
const socket =tls.connect({
host: 'myHost.com',
port: 3000 },
options, () => { console.log('client connected', socket.authorized ? 'authorized' : 'unauthorized');
process.stdin.pipe(socket);
process.stdin.resume(); });
socket.setEncoding('utf8');
socket.on('data', (data) => { console.log(data); }); socket.on('end', () => { console.log('server ends connection'); });









share|improve this question






















  • By the way, this does work with crypto.setEngine (engine_so, crypto.constants.ENGINE_MODE_ALL). Just not with tls @node/crypto
    – hbmaddog
    Nov 24 at 0:04

















up vote
2
down vote

favorite
1












Node.js Version: 11.2.0



OS: debian



Scope (install, code, runtime, meta, other?): issue with 'no client cert method' in tls handshake



Module (and version) (if relevant): openssl node tls clientCertEngine



Having issues with this trying to use a Hardware Security Module which stores the private key. (non readable/non exportable)



Without the HSM, there are no issues. Maybe I am calling clientCertEngine incorrectly? Or is there issue not allowing us to enter -keyform e?



although using s_client works as follows:



openssl s_client -host myHost.com -port 3000 -key fake.key -cert device.crt -CAfile ca.crt -engine hsm_engine -keyform e


When running client node tls connect:



_tls_common.js:204 c.context.setClientCertEngine(options.clientCertEngine);

Error: error:1412214B:SSL routines:SSL_CTX_set_client_cert_engine:no client cert method
at Object.createSecureContext (_tls_common.js:204:17)
at Object.connect (_tls_wrap.js:1205:48)
at Object. (/home/pi/test/tls.js:20:19)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
at startup (internal/bootstrap/node.js:300:19)


And the js code



const tls = require('tls');
const fs = require('fs');
const options = { // key: null //cannot be exported nor read. Ive tried with both null and removed key entirely
cert: fs.readFileSync('client.crt'),
clientCertEngine: '/path/to/hsm/.so file',
ca: [fs.readFileSync('ca.crt')], };
const socket =tls.connect({
host: 'myHost.com',
port: 3000 },
options, () => { console.log('client connected', socket.authorized ? 'authorized' : 'unauthorized');
process.stdin.pipe(socket);
process.stdin.resume(); });
socket.setEncoding('utf8');
socket.on('data', (data) => { console.log(data); }); socket.on('end', () => { console.log('server ends connection'); });









share|improve this question






















  • By the way, this does work with crypto.setEngine (engine_so, crypto.constants.ENGINE_MODE_ALL). Just not with tls @node/crypto
    – hbmaddog
    Nov 24 at 0:04















up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





Node.js Version: 11.2.0



OS: debian



Scope (install, code, runtime, meta, other?): issue with 'no client cert method' in tls handshake



Module (and version) (if relevant): openssl node tls clientCertEngine



Having issues with this trying to use a Hardware Security Module which stores the private key. (non readable/non exportable)



Without the HSM, there are no issues. Maybe I am calling clientCertEngine incorrectly? Or is there issue not allowing us to enter -keyform e?



although using s_client works as follows:



openssl s_client -host myHost.com -port 3000 -key fake.key -cert device.crt -CAfile ca.crt -engine hsm_engine -keyform e


When running client node tls connect:



_tls_common.js:204 c.context.setClientCertEngine(options.clientCertEngine);

Error: error:1412214B:SSL routines:SSL_CTX_set_client_cert_engine:no client cert method
at Object.createSecureContext (_tls_common.js:204:17)
at Object.connect (_tls_wrap.js:1205:48)
at Object. (/home/pi/test/tls.js:20:19)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
at startup (internal/bootstrap/node.js:300:19)


And the js code



const tls = require('tls');
const fs = require('fs');
const options = { // key: null //cannot be exported nor read. Ive tried with both null and removed key entirely
cert: fs.readFileSync('client.crt'),
clientCertEngine: '/path/to/hsm/.so file',
ca: [fs.readFileSync('ca.crt')], };
const socket =tls.connect({
host: 'myHost.com',
port: 3000 },
options, () => { console.log('client connected', socket.authorized ? 'authorized' : 'unauthorized');
process.stdin.pipe(socket);
process.stdin.resume(); });
socket.setEncoding('utf8');
socket.on('data', (data) => { console.log(data); }); socket.on('end', () => { console.log('server ends connection'); });









share|improve this question













Node.js Version: 11.2.0



OS: debian



Scope (install, code, runtime, meta, other?): issue with 'no client cert method' in tls handshake



Module (and version) (if relevant): openssl node tls clientCertEngine



Having issues with this trying to use a Hardware Security Module which stores the private key. (non readable/non exportable)



Without the HSM, there are no issues. Maybe I am calling clientCertEngine incorrectly? Or is there issue not allowing us to enter -keyform e?



although using s_client works as follows:



openssl s_client -host myHost.com -port 3000 -key fake.key -cert device.crt -CAfile ca.crt -engine hsm_engine -keyform e


When running client node tls connect:



_tls_common.js:204 c.context.setClientCertEngine(options.clientCertEngine);

Error: error:1412214B:SSL routines:SSL_CTX_set_client_cert_engine:no client cert method
at Object.createSecureContext (_tls_common.js:204:17)
at Object.connect (_tls_wrap.js:1205:48)
at Object. (/home/pi/test/tls.js:20:19)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
at startup (internal/bootstrap/node.js:300:19)


And the js code



const tls = require('tls');
const fs = require('fs');
const options = { // key: null //cannot be exported nor read. Ive tried with both null and removed key entirely
cert: fs.readFileSync('client.crt'),
clientCertEngine: '/path/to/hsm/.so file',
ca: [fs.readFileSync('ca.crt')], };
const socket =tls.connect({
host: 'myHost.com',
port: 3000 },
options, () => { console.log('client connected', socket.authorized ? 'authorized' : 'unauthorized');
process.stdin.pipe(socket);
process.stdin.resume(); });
socket.setEncoding('utf8');
socket.on('data', (data) => { console.log(data); }); socket.on('end', () => { console.log('server ends connection'); });






node.js openssl






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 13:47









hbmaddog

113




113












  • By the way, this does work with crypto.setEngine (engine_so, crypto.constants.ENGINE_MODE_ALL). Just not with tls @node/crypto
    – hbmaddog
    Nov 24 at 0:04




















  • By the way, this does work with crypto.setEngine (engine_so, crypto.constants.ENGINE_MODE_ALL). Just not with tls @node/crypto
    – hbmaddog
    Nov 24 at 0:04


















By the way, this does work with crypto.setEngine (engine_so, crypto.constants.ENGINE_MODE_ALL). Just not with tls @node/crypto
– hbmaddog
Nov 24 at 0:04






By the way, this does work with crypto.setEngine (engine_so, crypto.constants.ENGINE_MODE_ALL). Just not with tls @node/crypto
– hbmaddog
Nov 24 at 0:04



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394442%2fnodejs-clientcertengine%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394442%2fnodejs-clientcertengine%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen