ワイルドカードの SSL 自己署名証明書の作成
2012-02-22-1
名前ベースのバーチャルホストの検証のために、ワイルドカードなオレオレ証明書を作成。
なんてことはない、普通のオレオレ証明書の作り方とおなじ。
- 秘密鍵の作成
$ openssl genrsa -out server.key 2048
Generating RSA private key, 2048 bit long modulus
.....+++
..............+++
e is 65537 (0x10001)
- CSR の作成
$ openssl req -new -key server.key -out server.csr
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) [GB]:GB
State or Province Name (full name) [Berkshire]:Berkshire
Locality Name (eg, city) [Newbury]:Newbury
Organization Name (eg, company) [My Company Ltd]:My Company Ltd
Organizational Unit Name (eg, section) []:section
Common Name (eg, your name or your server's hostname) []:*.example.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
- 証明書作成 (10年)
$ openssl x509 -days 3653 -in server.csr -out server.crt -req -signkey server.key
Signature ok
subject=/C=GB/ST=Berkshire/L=Newbury/O=My Company Ltd/OU=section/CN=*.example.com
Getting Private key
この証明書を使って、特に問題なく、名前ベースのバーチャルホストができた。