0
1

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 3 years have passed since last update.

Windows Server+Open SSLでApacheが再起動できない場合の対処

Posted at

Windows ServerでIISではなくApache OpenSSLで証明書をインストールする際に、なんちゃって証明書では動いたのに正規の証明書に入れ替えるとApacheが再起動できなくなったため、その対処方法について備忘録として記載します。

先ずWindowsにApacheというと、多くの場合ローカルのPCにXampp等でインストールしてOpenSSLのなんちゃって証明書が動かないといったケースのトラブルが一般的ではないかと思います。
その場合は先ずは他のアプリケーションとのポートの競合を疑ってみてください。
netstatで見れば80番や443番を使用している他のアプリを確認できるので、Webサーバ側かアプリ側のポート番号に手を入れてあげれば解決します。

本件はレアケースだと思いますが、Windows Serverの場合の解消方法になります。
通常の場合ですとWindowsServerでポートが競合するようなアプリが動いていることはあまり考えられません。
従ってなんちゃって証明書まではインストールできて、とりあえずhttpsで警告は出るもののアクセスはできる状態になっているとします。
で正規の証明書を申請して入れ替えてみたらApacheが再起動できなくなったというトラブルに見舞われることがあります。
そんな時はApacheのエラーログを見てみましょう。

AH02577: Init: SSLPassPhraseDialog builtin is not supported on Win32 (key file C:/apache/conf/ssl.key/server.key)
AH02311: Fatal error initialising mod_ssl, exiting. See C:/apache/logs/error.log for more information
AH02564: Failed to configure encrypted (?) private key cloudshift.jp:443:0, check C:/apache/conf/ssl.key/server.key
SSL Library Error: error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag
SSL Library Error: error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error
SSL Library Error: error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag
SSL Library Error: error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error (Type=RSAPrivateKey)
SSL Library Error: error:04093004:rsa routines:old_rsa_priv_decode:RSA lib
SSL Library Error: error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag
SSL Library Error: error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error (Type=PKCS8_PRIV_KEY_INFO)
AH00016: Configuration Failed

ちょっとログの先頭部分を端折っていますがこんな感じのエラーが出ると思います。
一番最初のログに注目してください。

SSLPassPhraseDialog builtin is not supported on Win32 (key file C:/apache/conf/ssl.key/server.key)

要はWin32はSSLのパスフレーズには対応しておらんぞ!ワレ~ってことです。
証明書の申請時keyファイルを作る際、パスフレーズを登録していると思いますので、こいつを消してやる必要があります。
コマンドラインから以下の要領でパスフレーズ無しファイルを作成してください。

openssl rsa -in C:/apache/conf/ssl.key/server.key -out C:/apache/conf/ssl.key/nopassserver.key

パスフレーズを要求されますので入力してEnterします。
するとC:/apache/conf/ssl.key/nopassserver.key ができていると思いますので、あとはssl.confのkeyファイル名をnopassserver.key
に書き換えてAapcheを再起動すれば晴れて起動確認できます。

0
1
0

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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?