Generate Self Signed Certificate

Ive been generating self-signed certificates by using the following command:-
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

And then answer a series of questions:-
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:

Which works great, however I want to avoid having to type in  the answers. So my question is:-
Is it possible to enter these questions in the command line, or pass a file in with the answers?

What Im trying to do is build my own hosting admin page, and allow users to generate their own self certified SSL certificates on my ubuntu server, then add the certificates to the vHost configurations of apache.
Who is Participating?
Mark BullockQA Engineer IIICommented:
Try adding this on the end of your openssl command.
-subj "/C=AU/ST=NSW/L=Sydney/O=Internet Widgits Pty Ltd/OU=section/"

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.