通称、オレオレ証明書を発行を発行する手順を備忘録として書いていく。
解説とかはない、とりあえずオレオレ証明書が発行できればいい人向け。
2024/09/07 「サーバーの証明書要求を作成」を修正
2024/09/13 追記:完全版はこちら
認証局の秘密鍵を作成
$ openssl genrsa -des3 -out ca.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
....................................................+++++
..........................................................................................+++++
e is 65537 (0x010001)
Enter pass phrase for ca.key:password
Verifying - Enter pass phrase for ca.key:password
実際には入力したパスフレーズはコンソール上に表示されないので、忘れないようにしてください。
自己署名証明書を作成
$ openssl req -new -x509 -days 1826 -key ca.key -out ca.crt
Enter pass phrase for ca.key:password
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]:JP
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) []:localhost
Email Address []:
ca.keyのパスフレーズは認証局の秘密鍵で入力したパスフレーズを入力してください。
サーバーの秘密鍵を作成
$ openssl genrsa -out server.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
...........................................+++++
..............+++++
e is 65537 (0x010001)
サーバーの証明書要求を作成
$ openssl req -new -out server.csr -key server.key
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]:JP
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) []:localhost
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
証明書要求に署名する
$ openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 360 -sha256
Signature ok
subject=C = JP, ST = Some-State, O = Internet Widgits Pty Ltd, CN = localhost
Getting CA Private Key
Enter pass phrase for ca.key:password
ca.keyのパスフレーズは認証局の秘密鍵で入力したパスフレーズを入力してください。
成果物
$ tree
.
├── ca.crt
├── ca.key
├── ca.srl
├── server.crt
├── server.csr
└── server.key
コメント