Node-telegram-bot-api: Error: error:0906D06C:PEM routines:PEM_read_bio:no start line

Created on 19 Jan 2016  路  5Comments  路  Source: yagop/node-telegram-bot-api

Hello.

I have created crt and key files by using openssl as suggested here https://github.com/yagop/node-telegram-bot-api#webhooks

Then I wrote this code https://github.com/yagop/node-telegram-bot-api/blob/master/examples/httpsWebHook.js

And when I try to start it throws me this error:

 _tls_common.js:65
       c.context.setCert(options.cert);
                      ^

 Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
    at Error (native)
    at Object.createSecureContext (_tls_common.js:65:17)
    at Server (_tls_wrap.js:754:25)
    at new Server (https.js:24:14)
    at Object.exports.createServer (https.js:44:10)
    at new TelegramBotWebHook (d:\Phantasy  star\Mobi\Daniars_Project\Node\bot\node_modules\node-telegram-bot-api\src\telegramWebHook.js:23:29)
    at new TelegramBot (d:\Phantasy star\Mobi\Daniars_Project\Node\bot\node_modules\node-telegram-bot-api\src\telegram.js:54:21)
    at Object.<anonymous> (d:\Phantasy star\Mobi\Daniars_Project\Node\bot\main.js:19:11)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:429:10)
    at startup (node.js:139:18)
    at node.js:999:3

I have changed encoding of these files to UTF-8 and this does not work

docs

Most helpful comment

Maybe the path is wrong or Windows sucks.

PS: Windows sucks!

All 5 comments

Maybe the path is wrong or Windows sucks.

PS: Windows sucks!

I was having the same problem but on a ubuntu server.
The solution was generate the certificates using the following commands:

openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem
openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out server.crt

found it here : http://stackoverflow.com/questions/22584268/node-js-https-pem-error-routinespem-read-biono-start-line

Thanks @pedrostc, that worked for me.

Added a note on this error in our docs!

I am facing the same issue: PEM routines:PEM_read_bio:no start line

I have generated public key and private key by using ssh-keygen. and I am converting my public key in .pem format by using

ssh-keygen -f my_public_key_file -e -m PEM > my_new_pem_file

And I am getting my public key in PEM format in testCheckPEM file, I am updating this key in database and with the help of this public key i am trying to get encryped text, which i will use to decrypt with private key but that is next part) here is my code for encryption.
I am reading public key from database successfully and calling this function:

module.exports.encryptStringWithRsaPublicKey = (text, publicKey) => new Promise((resolve, reject) => {
try {
const buffer = new Buffer(text);
const options = { key: publicKey, padding: constants.RSA_PKCS1_PADDING };
const encrypted = crypto.publicEncrypt(options, buffer).toString('base64');
return resolve(encrypted);
} catch (ex) {
return reject(ex);
}
});

but always I am getting error 'no start line'
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line

What is wrong here? Any help will be appreciated.

here is my public key in ssh-keygen format:
ssh-rsa [MIKJ........JUIIK]

And here is my public key after PEM conversion :
-----BEGIN RSA PUBLIC KEY-----
[FRTYUH........HHKHJKK]
-----END RSA PUBLIC KEY-----

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abbddo picture abbddo  路  3Comments

dimawebmaker picture dimawebmaker  路  3Comments

lenny76 picture lenny76  路  3Comments

alikhil picture alikhil  路  3Comments

saeedhei picture saeedhei  路  4Comments