Trouble generating files

October 23, 2019 1.5k views
Docker

I am trying to create 3 required files ca.pen, cert.pem and key.pem. I am receiving errors when inputing commands and following the docker guide.

Here is an except from the terminal:

Enter pass phrase for ca-key.pem:
Can't load /root/.rnd into RNG
140347370283456:error:2406F079:random number generator:RAND_load_file:Cannot open file:../crypto/rand/randfile.c:88:Filename=/root/.rnd
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:Queensland
Locality Name (eg, city) []:Brisbane
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Docker Inc
Organizational Unit Name (eg, section) []:Sales
Common Name (e.g. server FQDN or YOUR name) []:206.189.187.199
Email Address []:Sven@home.org.au
root@docker-s-1vcpu-1gb-nyc1-01:~# openssl genrsa -out server-key.pem 4096
Generating RSA private key, 4096 bit long modulus (2 primes)
..........................................................................................................................................................................................................................................................................++++
.............................++++
e is 65537 (0x010001)
root@docker-s-1vcpu-1gb-nyc1-01:~# $ openssl req -subj "/CN=206.189.187.199" -sha256 -new -key server-key.pem -out server.csr
$: command not found
root@docker-s-1vcpu-1gb-nyc1-01:~# $ openssl req -subj "/CN=206.189.187.199" -sha256 -new -key server-key.pem -out server.csr
$: command not found
root@docker-s-1vcpu-1gb-nyc1-01:~# echo subjectAltName = DNS:206.189.187.199,IP:10.10.10.20,IP:127.0.0.1 >> extfile.cnf
root@docker-s-1vcpu-1gb-nyc1-01:~# echo extendedKeyUsage = serverAuth >> extfile.cnf
root@docker-s-1vcpu-1gb-nyc1-01:~# openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
>   -CAcreateserial -out server-cert.pem -extfile extfile.cn
Can't open extfile.cn for reading, No such file or directory
139925498274240:error:02001002:system library:fopen:No such file or directory:../crypto/bio/bss_file.c:72:fopen('extfile.cn','r')
139925498274240:error:2006D080:BIO routines:BIO_new_file:no such file:../crypto/bio/bss_file.c:79:
root@docker-s-1vcpu-1gb-nyc1-01:~# openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
>   -CAcreateserial -out server-cert.pem -extfile extfile.cnf
Can't open server.csr for reading, No such file or directory
140263526920640:error:02001002:system library:fopen:No such file or directory:../crypto/bio/bss_file.c:72:fopen('server.csr','r')
140263526920640:error:2006D080:BIO routines:BIO_new_file:no such file:../crypto/bio/bss_file.c:79:
root@docker-s-1vcpu-1gb-nyc1-01:~# 
root@docker-s-1vcpu-1gb-nyc1-01:~# openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
>  -CAcreateserial -out server-cert.pem -extfile extfile.cnf
Can't open server.csr for reading, No such file or directory
139985191776704:error:02001002:system library:fopen:No such file or directory:../crypto/bio/bss_file.c:72:fopen('server.csr','r')
139985191776704:error:2006D080:BIO routines:BIO_new_file:no such file:../crypto/bio/bss_file.c:79:

Any assistance or advice would be most appreciated

1 Answer

Hello,

It looks like that the input file that you are providing server.csr does not exist.

You need to either provide the full path to the server.csr file in your command or cd into the directory which contains the server.csr file and then run the openssl command.

Regards,
Bobby

Have another answer? Share your knowledge.