1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

はじめてのサーバ証明書 ~初心者なので勉強用に格安ドメインとテスト用証明書を取得してみる~

Last updated at Posted at 2016-03-16

SSL構築の勉強用に公式のサーバ証明書が欲しかったので取ってみた

格安ドメインは、GMOペパポのムームードメイン(https://muumuu-domain.com/)で、xxxx.scence を¥180/1年で取得

サーバ証明書を取得する時に、スキップ申し込みサービスを利用する場合、ドメインの存在認証のためにドメイン管理者に対してメールが飛ぶので管理者用のアカウントもムームーメールで¥600/1年で作成する

サーバ証明書はとりあえず、GMOグローバルサインで45日間有効のテスト用証明書を無料で作成する

ムームードメインで格安ドメインを作成する

以下の記事を参考に、xxxx.science ドメインと管理者のメールアカウント admin@xxxx.science を作成する

「バイラルクラブ > ブログ > ムームードメインで、ドメイン検索から取得・設定までの手順をまとめてみた」

テスト用サーバ証明書を発行する

以下のページから45日間有効のテスト用サーバ証明書が無料で発行できる。

「45日間のテスト用SSLサーバ証明書を無料発行」

発行される証明書はPKCS#12形式の一方で必要な証明書はPEM形式なのだが、以下のページを参考にopensslを使って変換できる

「[スキップ申込サービス]OpenSSLで証明書を変換する方法」

後で中間証明書も必要になるので、「クイック認証SSL用中間CA証明書(SHA256)」からダウンロードする

Windows版 Apache httpd.exe に組み込んでSSLのテストをしてみる

参考にする手順は以下のページ

「[スキップ申込サービス インストール] Apache 2.x + mod_ssl + OpenSSL(新規・更新)」

使用する Apache httpd.exe はApachehous ( https://www.apachehaus.com/cgi-bin/download.plx ) から、httpd-2.4.17-x64-vc11.zip をダウンロードした。

こいつはopenssl.exe も利用できるスグレモノ。

ダウンロードしたzipファイルは解凍して、C:\Apache24 フォルダに置いた。

Windows環境変数PATHに、C:\Apache24\bin を追加しておく

openssl.exeでプライベートキーとサーバ証明書を抽出し、中間証明書とともにC:\Apache24\conf\ssl に置く

サーバ証明書発行時に申請したCommonNameが自ホストを指すようにhostsを変更しておく

あとは先の手順の通り、opensslでPEM形式のプライベートキー、サーバ証明書を抽出してから、httpd-ahssl.conf のテスト用仮想ホスト設定(serverone.tld:443)の記述をコモンネームと証明書に合わせてこんな感じに書き換える

<VirtualHost *:443>
  SSLEngine on
  # ServerName serverone.tld:443
  # SSLCertificateFile "${SRVROOT}/conf/ssl/serverone.crt"
  # SSLCertificateKeyFile "${SRVROOT}/conf/ssl/serverone.key"
  ServerName aaa.xxxx.science:443
  SSLCertificateChainFile "${SRVROOT}/conf/ssl/gsdomainvalsha2g2.cer"
  SSLCertificateFile "${SRVROOT}/conf/ssl/globalsign.cer"
  SSLCertificateKeyFile "${SRVROOT}/conf/ssl/globalsign.key"
  DocumentRoot "${SRVROOT}/htdocs"
	CustomLog "${SRVROOT}/logs/ssl_request.log" \
        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
	<Directory "${SRVROOT}/htdocs">
		Options Indexes Includes FollowSymLinks
		AllowOverride AuthConfig Limit FileInfo
    Require all granted
	</Directory>
</virtualhost> 

この設定をした状態でhttpdを起動し、https://aaa.xxxx.science にアクセスして警告なしにApachehousのトップページが表示できれば完了

1
2
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?