0

There was many answer for this question but all are for windows. There had a same question for ubuntu but had no answer (Unable to open config file /usr/lib/ssl/openssl.cnf). When ran this command in my AWS ubuntu instance

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/example.com.key -out /etc/ssl/certs/example.com.crt

It shows the error above. That error start showing after delete the /etc/ssl folder from my instance. Please help me if anyone have solution.

Raisul Islam
  • 1,161
  • 1
  • 9
  • 18
  • "That error start showing after delete the /etc/ssl folder from my instance" That may be a clue that you should not have deleted `/etc/ssl` directory in the first place. Why did you do that? Just start again with a proper instance which has all the necessary directories to work, `/etc/ssl` being one of them... – Patrick Mevzek Oct 26 '18 at 21:27
  • yeah I know. But can anyone tell me what is the solution for this problem. – Raisul Islam Oct 27 '18 at 02:29
  • The solution to work when a needed file has been deleted? Either restore it from backup or just start a new instance from scratch and do not delete what you do not know how it is used. Otheriwe you can also add `-config` plus a filename to your command to point it to another name. – Patrick Mevzek Oct 27 '18 at 03:35

1 Answers1

0

I can tell you my case. The error that I found with Ubuntu 22.04 was this one:

Can't open /usr/local/bin/openssl/openssl.cnf for reading, Not a directory

I had to compile and install openssl from sources because the current version of openssl for this distro is 3.0.2 and I needed the 1.1.1n.

When I tried to generate a certificate with openssl I obtained the commented error, so I had to recompile from sources pointing to another directory:

wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz
tar -xf openssl-1.1.1n.tar.gz
cd openssl-1.1.1n
./config --openssldir=/opt/openssl
make
make install

The path for openssl is /usr/local/bin/openssl and now you can execute it without any problem.

The openssl.cnf is located in /opt/openssl/openssl.cnf

If you install openssl from APT the default config file is located in the directory /etc/ssl.

HarryKalahan
  • 11
  • 1
  • 5