Create a Self-Signed Certificate with one line openssl command

Codes


#!/bin/bash
openssl req -newkey rsa:4096 -nodes -sha256 \
-keyout certs/domain.key -x509 -days 365 \
-out certs/domain.crt \
-subj "/C=KR/ST=Seoul/L=Seongbuk/O=Korea University,\
Inc/CN=*.io/emailAddress=all4dich@gmail.com"

Files

  • certs/domain.key
    • Root CA Privat Key
  • certs/domain.crt
    • Self-Signed Certificate

How to view a certification file’s content on a shell

keytool -printcert -file certificate.pem

Example for Apache SSL configuration


SSLEngine on

SSLCertificateFile /home/sunjoo/work/docker_registry2/certs/domain.crt
SSLCertificateKeyFile /home/sunjoo/work/docker_registry2/certs/domain.key

Advertisements