'HAProxy Unable load SSL

I got this error

'bind *:443' : unable to load SSL certificate from PEM file '/etc/ssl/private/https-cert.pem'

but the file location is correct.

$ sudo ls -l  /etc/ssl/private/https-cert.pem
-rwxrwxrwx 1 root root 1660 Aug 27 12:56 /etc/ssl/private/https-cert.pem

My PEM File

-----BEGIN CERTIFICATE-----
MIICCjCCAXMCFFVlEFkJOqOR70jCfoTjeYUjghgzMA0GCSqG....
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDPyhixafaLSWhGlvYqKYslqUp3j8cF2RHx....
-----END RSA PRIVATE KEY-----

I've also tried all the methods in this link: haproxy - unable to load SSL private key from PEM file, but still having problems.

Please help me, I'm desperate to fix it.



Solution 1:[1]

I am not realy into it, bit i might lead to the right path ... (had to deal with that too and got it fixed)

created pem with (please be smart enought to move your secrets away once it is running ;-) )

cd /etc/haproxy/
mkdir certs
cd certs/
openssl req -newkey rsa:2048 -nodes -x509 -days 365 -keyout haproxy2.key -out haproxy2.crt -subj "/CN=<yourServerName>"
cat haproxy2.crt haproxy2.key haproxy2.pem
cat haproxy2.crt haproxy2.key > haproxy2.pem

modified haproxy.cfg to look like... (path should be full path)

  bind :::8181 ssl crt /etc/haproxy/certs/haproxy2.pem

further might be good to check that haproxy is compiled with proper SSL by

haproxy -vv

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ma Ha