-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Public key and TLS ? #1472
Comments
I believe @koichik: can you maybe add documentation? |
okay, I will write it. |
I'm using Node v0.4.10 and getPeerCertificate does not work (or I do not have the necessary knowledge to use it.)
getPeerCertificate is empty ?! |
What type of client you use? Browsers by default don't use any certificates, so double check that the client is configured to authenticate itself using a certificate. |
I simply use openssl s_client -connect 127.0.0.1 . But I'm not interested by the certificate, I simply want the public key used by the client. |
Did you set |
var options = { And is returns the same thing as before. |
If you use self-signed certificate on your client, you should set var tls = require('tls'), fs = require('fs');
var options = {
key: fs.readFileSync('server-key.pem'),
cert: fs.readFileSync('server-cert.pem'),
ca: [fs.readFileSync('client-cert.pem')],
requestCert: true
};
tls.createServer(options, function (socket) {
console.log(socket.getPeerCertificate());
socket.end('Hello, World!');
}).listen(8124, '127.0.0.1');
result:
|
Which public key? In case of openssl s_client -connect 127.0.0.1 generated diffie-hellman or RSA public key is random and is of no use. If you want to use a keypair and not a full X.509 certificate, you should pass them to s_connect (see -key client-key.pem -cert client-cert.pem above). Without -key and -cert openssl s_connect generates a temporary keypair which cannot be used to identify client. |
@nponeccop I use this command only for my tests. @koichik It is not possible to find the fingerprint of the public key of the customer without going through the system of trusted certificates ? |
It is possible to use just key pairs without a public key infrastructure. But every client has to generate and use a non-temporary key pair. |
That's what I want to do. If you don't understand me, keep me informed. |
Koichik used "non-trusted" (self-signed) certificates. Will that work for you? |
@bnoordhuis - Please review d30251c. |
Thank you for your help. |
I'm sorry for the UP, but I have this problem again ... the other way!
|
Please try this: _CONFIG.certs = {
key: fs.readFileSync('./clefs/Clef-privee.key'),
cert: fs.readFileSync('./clefs/certification-Serveur.key'),
ca: fs.readFileSync('./clefs/certification-de-autorite.key'),
requestCert: true
};
var port = 4628;
tls.createServer(_CONFIG.certs, function (s) {
console.log(s.getPeerCertificate().fingerprint); // It OK
}).listen(port, function() {
var s2 = tls.connect(port, 'localhost', // return value!
_CONFIG.certs, function() { // no arg!
console.log(s2.getPeerCertificate().fingerprint);
});
}); |
Hello, and sorry for my bad English.
I can not find the API documentation of the TLS module which retrieves the public key of the client that connects to my server.
You have an idea?
Thank you!
The text was updated successfully, but these errors were encountered: