Deprecated: Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 63

Deprecated: Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 73

Deprecated: Return type of Requests_Cookie_Jar::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 89

Deprecated: Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 102

Deprecated: Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 111

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 51

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 82

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 91

Deprecated: Return type of AIOSEO\Plugin\Common\Models\Model::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 409

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174
Apache httpdにワイルドカードの自己証明SSLを設定 | reyfox blog

reyfox blog

reyfox tech info

Apache2.4系 CentOS Linux

Apache httpdにワイルドカードの自己証明SSLを設定

投稿日:

現在では常時SSL化が流行ってきていてローカルの開発時でもSSL化しておくとWebアプリケーションを作ったときに検証などしやすくなります。

毎回サブドメインごとに自己証明のSSLを発行するのが面倒なので、ワイルドカードのSSLを発行します。

なお、自己証明なので、ブラウザの警告は出ます。ブラウザ側で設定を変えるなどしてアクセスするようにしてください。

今回のドメイン: reyfox.lo(内向きDNSで設定しているドメインとなります)

秘密鍵を作成する

まず以下のコマンドで秘密鍵を作成します。


cd /etc/pki/tls/certs
openssl genrsa -aes128 2048 > wild.key
Generating RSA private key, 2048 bit long modulus
......+++
......................+++
e is 65537 (0x10001)
Enter pass phrase:
Verifying - Enter pass phrase:

作成するときにパスフレーズが求められます。(ブランク不可)これは必須ですがサーバの起動ごとに聞かれるのでパスフレーズを削除します。

秘密鍵のパスフレーズの削除


openssl rsa -in wild.key -out wild.key.out
Enter pass phrase for wild.key:
writing RSA key
rm wild.key
mv wild.key.out wild.key

wild.key.outにパスフレーズなしの秘密鍵を作成し、その後パスフレーズありの秘密鍵を削除し、wild.key へとリネームします。

CSRの発行


openssl req -new -key wild.key > wild.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) [XX]:JP
State or Province Name (full name) []:
Locality Name (eg, city) [Default City]:
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:*.reyfox.lo
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

内容は適当で良いですが Common Nameの部分だけ、*.ドメイン名にします。

自己証明する(通称オレオレ証明書)


openssl x509 -in wild.csr -days 36500 -req -signkey wild.key > wild.crt
Signature ok
subject=/C=JP/L=Default City/O=Default Company Ltd/CN=*.reyfox.lo
Getting Private key

期限は普通1年や2年ですが開発用なので100年にします。

あとは yum で mod_ssl をインストールし、config ファイルを作成します。(例: /etc/httpd/conf.d/ssl.conf)


SSLCertificateFile /etc/pki/tls/certs/wild.crt
SSLCertificateKeyFile /etc/pki/tls/certs/wild.key

上記のように発行したオレオレ証明書と秘密鍵を設定するだけでワイルドカードSSLの設定が完了します。

なお上記の証明書はApacheだけでなくnginxなどでも使用できます。

先にも書きましたがもちろん第三機関に認証されてないオレオレ証明書なのでブラウザの警告はでるので例外として登録しておく必要があります。

-Apache2.4系, CentOS, Linux

執筆者:

関連記事

CentOS7上でUSB温度計で温度を記録してgrafanaでグラフ化する

AmazonでUSBで温度(室温)が図れるデバイスが売っていたのでこれをCentOS7で動いているNUCにつなげて温度をグラフ化してみたいと思います。 やりたいこと USBで温度を計測、その値をinf …

CentOS7にSambaサーバを立ててWindows/Macとファイルを共有する

Linux上にsambaサーバを立てて、Windows及びMacとファイル共有をします。 ストレージは以前増設した3TBのHDDを用いて3TBすべてを共有してNASのように使用します。 Intel N …

CentOS7にPHP 7.2をインストール

WebプログラミングでおなじみPHPをインストール設定します。PHPは現在では最新が7.2となっていて、CentOS7標準のリポジトリで提供されている5.4は古いのでインストールしません。 インストー …

CentOS7にMySQLサーバ(mariaDB)をインストールする

CentOS7からMySQLにかわりmariaDBが採用されていますが、使い方はほぼ MySQLと同じでいけます。 インストール いつもの通り、yumで。 yum install mariadb-se …

CentOS7で内向き専用DNSサーバを立てる

内向きDNSとは、LAN内でだけドメイン名を解決できるDNSサーバを言います。今回は、LAN内だけでドメイン名を解決するDNSサーバを立て、デフォルトのDNSとして動作するように設定します。なお、内向 …


Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174