0

I have searched the website and found some answers but it didn't solve my problem, And I don't know what's I am doing is correct or not.

My website is php based, for chat I am using nodejs, and socket.io it was working fine without http. Both are in the same same server. Now the main site moved to https, so i tried to use https in socket server

I used the following code to add cerficate information:

var server = https.createServer({
  key: fs.readFileSync('./ssl/private.key'),
  cert: fs.readFileSync('./ssl/mycert.crt')
},app).listen(3000);

At first I used self signed certificate, but it showed some error in the browser.

So I tried to use the certificates and private key used for the main (php) website. so I logged into cpanel-> ssl/tls section

and found

Private Keys (KEY)

Generate, view, upload, or delete your private keys.

Certificate Signing Requests (CSR)

Generate, view, or delete SSL certificate signing requests.

Certificates (CRT)

Generate, view, upload, or delete SSL certificates.

Install and Manage SSL for your site (HTTPS)

Manage SSL sites.

so I copied the currently used ssl certificate as mycert.crt from Certificates (CRT) and copied corresponsing key from Private Keys (KEY) section as private.key and used in the

var server = https.createServer({
  key: fs.readFileSync('./ssl/private.key'),
  cert: fs.readFileSync('./ssl/mycert.crt')
},app).listen(3000);

But when I run node index.js

it shows the following error:

_tls_common.js:105 c.context.setKey(options.key, options.passphrase); ^

Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch at Object.createSecureContext (_tls_common.js:105:17) at Server (_tls_wrap.js:794:25) at new Server (https.js:54:14) at Object.createServer (https.js:76:10) at Object. (/home/myimsuite/public_html/chat-server/index.js:19:20) at Module._compile (module.js:569:30) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3)

  • "The trck" is to search for the exact search message (which actually comes from the libssl (which is provided by OpenSSL)). Here is the ready-made search query (use double quotes when googling). The first several links there answer your question. – kostix Oct 26 '18 at 15:39
  • To cite the text from the first search result: «The "modulus" and "public exponent" portions in the key and the certificate must match exactly.». So my guess is that the key does not actually matches the cert—as simple as that. – kostix Oct 26 '18 at 15:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.