Recently i was migrating an Apache HTTP Server (httpd) server from one linux machine to another. The problem was, that on the source linux machine Apache HTTP Server (httpd) was a custom compiled 2.4.4 and we were having constant problems when patching the linux machine (openssl libraries etc.). So we decided to replace the custom compiled Apache HTTP Server (httpd) with the RPM version of it but still wanted to stay on 2.4.X version – do not like going back to CentOS/RHEL repository 2.2 Apache HTTP Server versions.
Since all our machines are virtual machines, it is much easier to deploy a new virtual machine from template, install & update the required RPM packages and migrate the apache configuration to the new linux machine – and it is way more cleaner too! 🙂
I built the latest Apache HTTP Server RPM (version 2.4.9) which i also described in THIS how to and started the process of migration – just for additional info, our Apache HTTP Server instance is only used as a proxy server.
So after installing the Apache HTTP Server 2.4.9 from RPM and transfering the Apache HTTP Server configuration from the source machine i tried to start Apache to check if any errors exist (ofcourse small configuration change was inevitable). The Apache HTTP Server would not start, it said FAILED and the error in /var/log/httpd/ssl_error.log was:
[Fri Aug 08 15:40:30.908717 2014] [ssl:emerg] [pid 8242:tid 139656074909504] AH02562: Failed to configure certificate 192.168.1.3:443:0 (with chain), check /etc/httpd/ssl/geekpeek.cer [Fri Aug 08 15:40:30.908864 2014] [ssl:emerg] [pid 8242:tid 139656074909504] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: TRUSTED CERTIFICATE) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile? [Fri Aug 08 15:40:30.908888 2014] [ssl:emerg] [pid 8242:tid 139656074909504] SSL Library Error: error:140DC009:SSL routines:SSL_CTX_use_certificate_chain_file:PEM lib
Let’s Fix SSL Library Error: error:0906D06C:PEM – Apache Error!
1. Check Certificate With OpenSSL
I started checking certificate key and certificate for errors. After checking certificate /etc/httpd/ssl/geekpeek.cer this is what i got:
[root@geekpeek ~]# openssl x509 -in /etc/httpd/ssl/geekpeek.cer -text -noout unable to load certificate 140028248876872:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE
This “SSL Library Error: error:0906D06C:PEM” error is the same error we get in /var/log/httpd/ssl_error.log.
A bit of googling got me to THIS great webpage which says i quote “If you get the folowing error it means that you are trying to view a DER encoded certifciate and need to use the commands in the “View DER encoded certificate below””. This is good news for us!
2. View DER Encoded Certificate With OpenSSL
By running the following command i confirmed that the certificate was in DER format since the DID NOT exit with “SSL Library Error: error:0906D06C:PEM” error again but showed certificate information:
[root@geekpeek ~]# openssl x509 -in /etc/httpd/ssl/geekpeek.cer -inform der -text -noout Certificate: Data: Version: 3 (0x2) Serial Number: ......
3. Convert DER Certificate To PEM With OpenSSL
For Apache to be able to read the certificate and therefore successfully start we need to convert DER certificate to PEM by running the following command:
[root@geekpeek ~]# openssl x509 -inform der -in /etc/httpd/ssl/geekpeek.cer -out /etc/httpd/ssl/geekpeek.pem
And voila!
Change the Apache configuration to point to the newly created PEM certificate and Apache should start without “SSL Library Error: error:0906D06C:PEM” error!
I’ve been setting up SSL for my domain today, and have struck another issue — I was hoping someone could shed some light on..
I keep receiving the following error messages:
[error] Init: Unable to read server certificate from file /etc/apache2/domain.com.ssl/domain.com.crt/domain.com.crt [error] SSL Library Error: 218529960 error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag [error] SSL Library Error: 218595386 error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error
I’m running Apache 2.2.16 and Ubuntu 10.10. My .crt file has the Begin and End tags, and has been copied exactly from the confirmation email I received, very frustrating!
Cheers!
Edit >>
When trying to verify the .crt It doesn’t seem to work:
>> openssl x509 -noout -text -in domain.com.crt unable to load certificate 16851:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:650:Expecting: TRUSTED CERTIFICATE
Also >>
>> openssl x509 -text -inform PEM -in domain.com.crt unable to load certificate 21321:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:650:Expecting: TRUSTED CERTIFICATE
>> openssl x509 -text -inform DER -in domain.com.crt unable to load certificate 21325:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1316: 21325:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:380:Type=X509
Edit>>
(Cheers for the help by the way)
>> grep '^-----' domain.com.crt -----BEGIN CERTIFICATE----- -----END CERTIFICATE-----
Just emailed the company providing the Certificate, they responded>
I have checked the CSR file that you have provided and I can assure
that this was correctly generated. The error that you are currently
encountering is caused because you are using a wrong command line for
installing the CSR. You will need to modify this domain.com.crt from
your command line with the according name of your domain.
- currently the crt is set up to mysite.com.crt — I’ve used domain.com.crt as an example
I can reproduce this error by trying to use a key or cert file which does not contain correctly encoded data.
For instance. I have a file key.pem which contains
——BEGIN RSA PRIVATE KEY——
MIIEowIBAAKCAQEAsG240gudCfVVcAtFKFOl90xOCnyTam56kx1O4V3dsXWg0k6H
[…..]
ZFQngI7aVAmzgLXAx+8U41Z0bcxsc9HXeJGRRYawHsaLvBRJ05Ge
——END RSA PRIVATE KEY——
If I use the key correctly, the connection works. If I remove the first line “——BEGIN RSA….” and try again, then the same error occurs as you have seen. The error is caused by the PEM parse being unable to find the start line, hence the “no start line” error.
I am surprised that openssl connects correctly but I would advise that you double check you are referencing the correct certificates/keys.
One thing that might be worth trying is:
openssl rsa -text -in
Regards,
—A
On 10 Dec 2014, at 06:38, NizarBlond notifications@github.com wrote:
I’m trying to send push notification to the server using PEM certs that I generated and tested on OPENSSL, but I keep getting exception that crashes my node app.
Certificate Test:
openssl s_client -connect gateway.push.apple.com:2195 -cert certdist.pem -key keydist.pem
CONNECTED(00000003)
ExceptionError: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Object.exports.createCredentials (crypto.js:129:17)
at apnSocketLegacy (/app/node_modules/apn/lib/socket.js:40:19)
at Connection.initialize.spread.fail.terminated (/app/node_modules/apn/lib/connecat /app/node_modules/apn/node_modules/q/q.js:1171:26 at _fulfilled (/app/node_modules/apn/node_modules/q/q.js:794:54) at self.promiseDispatch.done (/app/node_modules/apn/node_modules/q/q.js:823:30) at Promise.promise.promiseDispatch (/app/node_modules/apn/node_modules/q/q.js:756 at /app/node_modules/apn/node_modules/q/q.js:516:49 at flush (/app/node_modules/apn/node_modules/q/q.js:110:17)This is happening when called from:
apnConnection.pushNotification(note, tokens);Ideas?
—
Reply to this email directly or view it on GitHub #234.
Модераторы: Art.i, vasya
Сертификат Let’s Encrypt для панели ISPmanager
Получил сертификат Let’s Encrypt с помощью плагина для своего домена example.com. Этот домен привязан к тому же IP, что и панель ISPmanager. По адресу
https://example.com:1500/ispmgr
открывается панель, но не с сертификатом Let’s Encrypt, а уже с самоподписанным сертификатом. Как настроить сертификат, чтоб он работал с панелью?
Заменить порт в блоке <VirtualHost xxx.xxx.xxx.xxx:443> на 1500 или продублировать блок с указанием порта 1500?
Или может для панели нужно указать порт 443?
- ijkl
- Сообщений: 194
- Зарегистрирован: Чт окт 03, 2013 5:42 pm
Re: Сертификат Let’s Encrypt для панели ISPmanager
ls » Пн авг 08, 2016 4:33 pm
Я думаю в данном случае проще скачать файлы сертификата из /var/www/httpd-certs и установить в Адреса панели
- ls
- Support team
- Сообщений: 6352
- Зарегистрирован: Чт мар 01, 2007 10:36 am
- Откуда: FirstVDS
Re: Сертификат Let’s Encrypt для панели ISPmanager
ijkl » Пн авг 08, 2016 6:16 pm
Там есть 4 файла: .crt, .key, .ca, .crtca.
Сделал так:
В поле SSL сертификат вставил содержимое файла .crt
В поле Ключ SSL сертификата вставил содержимое файла .key
Поле Цепочка SSL-сертификатов оставил пустым.
Не работает.
Что находится в .ca и .crtca.?
- ijkl
- Сообщений: 194
- Зарегистрирован: Чт окт 03, 2013 5:42 pm
Re: Сертификат Let’s Encrypt для панели ISPmanager
ls » Пн авг 08, 2016 6:57 pm
Цепочку укажите из файла .ca
- ls
- Support team
- Сообщений: 6352
- Зарегистрирован: Чт мар 01, 2007 10:36 am
- Откуда: FirstVDS
Re: Сертификат Let’s Encrypt для панели ISPmanager
ijkl » Пн авг 08, 2016 7:11 pm
Повторил все шаги, и дополнительно указал содержимое .ca в поле Цепочки — все равно не работает.
Попробовал указать в этом поле содержимое .crtca
В рещультате: Возникла ошибка при работе с ключами или сертификатами. Не удалось прочитать сертификат из x509 формата error:0906D06C:PEM routines:PEM_read_bio:no start line
И теперь при любой попытке, даже при указании содержимого .ca, сообщает об этой ошибке.
- ijkl
- Сообщений: 194
- Зарегистрирован: Чт окт 03, 2013 5:42 pm
Re: Сертификат Let’s Encrypt для панели ISPmanager
ls » Вт авг 09, 2016 2:42 am
Надо указывать содержимое ca файла, а не .crtca
В данном случае можно написать запрос в поддержку, чтобы мы посмотрели на месте
- ls
- Support team
- Сообщений: 6352
- Зарегистрирован: Чт мар 01, 2007 10:36 am
- Откуда: FirstVDS
Вернуться в Безопасность
Кто сейчас на форуме
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 0
I am trying to generate a private-public key pair and convert the public key into a certificate which can be added into my truststore.
To generate private & public key: openssl rsa -in private.pem -outform PEM -pubout -out public_key.pem
Now I am trying to convert this to a certificate:
openssl x509 -outform der -in public_key.pem -out public.cer
But I get an error:
7962:error:0906D06C:PEM routines:PEM_read_bio:no start line:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-64.30.2/src/crypto/pem/pem_lib.c:648:Expecting: TRUSTED CERTIFICATE
All tutorials show that I have to convert pem to crt before adding to a truststore.
asked Feb 8, 2017 at 17:30
You cannot «convert» a public key to a certificate. A certificate includes the public key but it includes also more information like the subject, the issuer, when the certificate is valid etc. And a certificate is signed by the issuer.
Thus what you would need instead is to create a certificate signing request (CSR) which includes the public key but also includes all the additional information. This CSR then needs to be signed by a certificate authority (CA) which then results in the certificate.
For creating a simple self-signed certificate which is not trusted by any browser see How to create a self-signed certificate with openssl?.
answered Feb 8, 2017 at 17:38
Steffen UllrichSteffen Ullrich
189k29 gold badges374 silver badges431 bronze badges
2
You cannot convert a public key into a certificate.
The original commands will not work since the PEM encoding / file format is expecting to contain the encrypted certificate text like below:
——BEGIN CERTIFICATE——
Certificate data here
——END CERTIFICATE——
Therefore if you view the original .PEM file and see something else (like BEGIN RSA … ) then that is incorrect.
Now according to the thread title you are seeking to convert a PEM into a CRT file format. Note that x509 certificates can be in two encodings — DER and PEM. Also, PEM can be within a .CRT, .CER and also .PEM format.
Therefore if you see that error there is also a chance that you are treating a DER encoded certificate as a PEM encoded certificate. You can try to see if it’s actually DER encoded by following the instructions in this page.
answered Feb 8, 2017 at 22:47
NASAhorseNASAhorse
3101 silver badge7 bronze badges
Going crazy trying to solve error on Node.js while trying to contact Xero API.
I’ve used a bunch of combinations of ‘.cer’ and ‘.crt’ and ‘.pem’.
I’ve followed the advice of a number of StackOverflow posters.
Node.js https pem error: error:0906D06C:PEM routines:PEM_read_bio:no start line
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Sign.sign (crypto.js:327:26)
at Xero.oa._createSignature (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/index.js:19:68)
at exports.OAuth._getSignature (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/node_modules/oauth/lib/oauth.js:90:15)
at exports.OAuth._prepareParameters (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/node_modules/oauth/lib/oauth.js:300:16)
at exports.OAuth._performSecureRequest (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/node_modules/oauth/lib/oauth.js:309:31)
at Xero.call (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/index.js:51:20)
at /Users/BeardedMac/projects/clause/clause-mean-stack/routes/external.js:47:10
at Layer.handle [as handle_request] (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/layer.js:95:5)
at /Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/index.js:330:12)
at next (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/index.js:271:10)
at expressInit (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/middleware/init.js:33:5)
Anyone out there have some insight?
The Xero API says it wants an X509 certificate…I’m not even making the call though.
asked Aug 1, 2016 at 16:09
You need a PEM-encoded key as the xero module merely calls out to node’s built-in crypto module to sign some data. Those types of keys start with
-----BEGIN RSA PRIVATE KEY-----
and end with
-----END RSA PRIVATE KEY-----
with base64-encoded data in between.
You can generate such a key using the openssl command-line utility:
openssl genrsa -out privateKey.pem 2048
Then read privateKey.pem in node like:
var fs = require('fs');
var privateKey = fs.readFileSync('/path/to/privateKey.pem');
// pass `privateKey` as the RSA private key to the `xero` module ...
answered Aug 1, 2016 at 16:15
mscdexmscdex
103k15 gold badges191 silver badges151 bronze badges
6
Check your certificate format. Carriage return(r) and new line(n) should be there in the .cer or .crt format. Postman expects this.
This can be verified by opening it in notepad.
answered Aug 10, 2021 at 10:17
Going crazy trying to solve error on Node.js while trying to contact Xero API.
I’ve used a bunch of combinations of ‘.cer’ and ‘.crt’ and ‘.pem’.
I’ve followed the advice of a number of StackOverflow posters.
Node.js https pem error: error:0906D06C:PEM routines:PEM_read_bio:no start line
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Sign.sign (crypto.js:327:26)
at Xero.oa._createSignature (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/index.js:19:68)
at exports.OAuth._getSignature (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/node_modules/oauth/lib/oauth.js:90:15)
at exports.OAuth._prepareParameters (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/node_modules/oauth/lib/oauth.js:300:16)
at exports.OAuth._performSecureRequest (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/node_modules/oauth/lib/oauth.js:309:31)
at Xero.call (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/xero/index.js:51:20)
at /Users/BeardedMac/projects/clause/clause-mean-stack/routes/external.js:47:10
at Layer.handle [as handle_request] (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/layer.js:95:5)
at /Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/index.js:330:12)
at next (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/router/index.js:271:10)
at expressInit (/Users/BeardedMac/projects/clause/clause-mean-stack/node_modules/express/lib/middleware/init.js:33:5)
Anyone out there have some insight?
The Xero API says it wants an X509 certificate…I’m not even making the call though.
asked Aug 1, 2016 at 16:09
You need a PEM-encoded key as the xero module merely calls out to node’s built-in crypto module to sign some data. Those types of keys start with
-----BEGIN RSA PRIVATE KEY-----
and end with
-----END RSA PRIVATE KEY-----
with base64-encoded data in between.
You can generate such a key using the openssl command-line utility:
openssl genrsa -out privateKey.pem 2048
Then read privateKey.pem in node like:
var fs = require('fs');
var privateKey = fs.readFileSync('/path/to/privateKey.pem');
// pass `privateKey` as the RSA private key to the `xero` module ...
answered Aug 1, 2016 at 16:15
mscdexmscdex
103k15 gold badges191 silver badges151 bronze badges
6
Check your certificate format. Carriage return(r) and new line(n) should be there in the .cer or .crt format. Postman expects this.
This can be verified by opening it in notepad.
answered Aug 10, 2021 at 10:17

