Linuxパソコンのこと

SSLサーバー証明書 openssl 秘密鍵のパスフレーズを削除

1 Mins read

さてサーバー証明書の秘密鍵が暗号化されたままだとApache起動時にパスワード入力を求められて、再起動後とか起動が止まってしまうことを防ぎたい。

また一台のApacheで複数のURLをVirtualHostにて運用している且つ複数のSSL設定している場合、パスフレーズファイル読み込み指示「SSLPassPhraseDialog 」が出来ない。

なのでパスフレーズカットが気持ちいいね♪

元ファイルのバックアップ
# cp sslhoge.key sslhoge.key.org
パスフレーズの解除
# openssl rsa -in sslhoge.key -out sslhoge.key.none

新しく生成するファイル名を「none」などと別ファイル名とし名前変更することが大切!
エラーにならないけど同じファイル名だと上書きされないで、生成できていないから注意すること!
# openssl rsa -in sslhoge.key -out sslhoge.key.none

エディッタで開くとちゃんとパスフレーズが取れたか分かる

■暗号化されているとこんな感じ
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,35GBFG546FC042B7
 
bLpCb3csi5WDZpaUYhJ5IT2eB6lnuojsPxqS2r0ee+8Gzfu9KyO7/AVmN95XD6Go
n/0d1L341hsJZLPoATzGXLslRSKeSeakI22yZF0Fl6hYrs8rs/aToyUCgYEA3cq1
e/a4VfdRDqLV4ZDfxyP0+yLS+E4WpFi5V83RObfzer1cQs6Z+DV5RRwy8b1VIJjM
XqWr5TplNc/pcFfrEPegw86t1xw6qIh0rDapZd6oxlXkeWJyWOrCMEfXsCEBFz/v
j0RXKPHVndOyP1RBXR0ZgdiFUqOKchRfh/O8r4RzGPkb32+/umqPPU1McXOjkvVO
・・・

■パスフレーズが取れた場合はこんな感じ
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIPURFCAQEA0q0ObXRi1L5mRYWNFGBFJsasTOdTlU0IK9I+S8OWnYJyBU/a
n/0d1L641hsJZLPoATzGXLslRSKeSeakI22yZF0Fl6hYrs8rs/aToyUCgYEA3cq1
yLXgRIJ5oBFkSaK35/qn8lc6pmPZ/dHrJxl3WfPDn3VgIH/m2uhJca1N9oFNPLoz
j3RXKPHVndOyP1RBXR0ZgdiFUqOKchRfh/O8r4RzGPkb32+/umqPPU1McXOjkvVO
yLXgRIJ5oBFkSaK35/qn8lc6pmPZ/dHrJxl3WfPDn3VgIH/m2uhJca1N9oFNPLoz
・・・

しっかりと確認すること♪

Read more
Linux日記

CentOS 6.9 (64bit) に xampp linux x64 5.6.31 をインストール

3 Mins read

久しぶりに環境設定で少しハマったので書き込み

CentOS 6.9 (64bit) にxampp linux x64 5.6.31 をインストールしたら以下のエラーで起動できない。

# ./lampp start
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/bin/bash: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
 
id: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/share/xampp/xampplib: line 11: test: -ne: unary operator expected
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
XAMPP: egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/httpd: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
XAMPP: hostname: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/bin/sh: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
XAMPP: egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

「libc.so.6」ライブラリが無いか?環境変数のPathがおかしいんだろうと決め込んで確認コマンド投げる

yumで確認
#yum provides */libc.so.6
 
読み込んだプラグイン:fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
base/filelists_db | 6.4 MB 00:00
extras/filelists_db | 25 kB 00:00
updates/filelists_db | 2.9 MB 00:00
glibc-2.12-1.209.el6.x86_64 : The GNU libc libraries
リポジトリー : base
一致 :
ファイル名 : /lib64/libc.so.6
 
glibc-2.12-1.209.el6.i686 : The GNU libc libraries
リポジトリー : base
一致 :
ファイル名 : /lib/i686/nosegneg/libc.so.6
ファイル名 : /lib/libc.so.6
 
glibc-2.12-1.209.el6_9.1.i686 : The GNU libc libraries
リポジトリー : updates
一致 :
ファイル名 : /lib/i686/nosegneg/libc.so.6
ファイル名 : /lib/libc.so.6
 
glibc-2.12-1.209.el6_9.2.i686 : The GNU libc libraries
リポジトリー : updates
一致 :
ファイル名 : /lib/i686/nosegneg/libc.so.6
ファイル名 : /lib/libc.so.6
 
glibc-2.12-1.209.el6_9.2.x86_64 : The GNU libc libraries
リポジトリー : updates
一致 :
ファイル名 : /lib64/libc.so.6
 
glibc-2.12-1.209.el6_9.1.x86_64 : The GNU libc libraries
リポジトリー : updates
一致 :
ファイル名 : /lib64/libc.so.6
 
glibc-2.12-1.209.el6_9.2.x86_64 : The GNU libc libraries
リポジトリー : installed
一致 :
ファイル名 : /lib64/libc.so.6
 
glibc-2.12-1.209.el6_9.2.i686 : The GNU libc libraries
リポジトリー : installed
一致 :
ファイル名 : /lib/i686/nosegneg/libc.so.6
ファイル名 : /lib/libc.so.6

いるね~

なんじゃ?リンク切れか?。。。リンクあるし???
はて?

起動時にエラー?

起動ファイルlampp=xamppファイルなのでviでオープンし中身確認

どうやら起動時のOSバージョンチェックで読み込み先共通ライブラリが違っていることが原因見たいだけど、このエラーメッセージからはそんなこと読み取れん!Cのデバッグと同じで落ちている箇所やエラーメッセージに騙されてはいかんやつやな(笑)本質の問題を見分ける所は。。。人生と同じか(苦笑)

CentOSのバージョン確認「2.6.32」部分がキーとなっておりこれを超えているか?のチェックっぽい
#more /proc/version
Linux version 2.6.32-696.13.2.el6.x86_64 (mockbuild@c1bl.rdu2.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) ) #1 SMP Thu O
ct 5 21:22:16 UTC 2017

viでxamppを開き436行目の
「export LD_ASSUME_KERNEL=2.2.5」

「export LD_ASSUME_KERNEL=2.8.0」
へ変更してあげる

こんな感じ
# do we have that new red hat linux 9 with posix native threads?
if test $(osguess) = "rh9"
then
# for now disable PNTL. if PNTL gets more popular we will support it. - oswald [8apr3]
export LD_ASSUME_KERNEL=2.8.0
#echo "XAMPP: DISABLE PNTL..."
fi

これで無事起動♪
#./lampp start

Read more
LinuxRouterWindows Server

DNS 再帰的な問い合わせ DDos攻撃について

1 Mins read

世の中の「DNS の再帰的な問い合わせを使った DDoS 攻撃」が相変わらず多いようです。

公開している外向きのDNSサーバーは再帰的な問合せをローカルIP以外からは使用できないよう設定する必要がありますが、昔のDNSサーバーは標準で外向きにも答えるようになっているものが多いみたいです。今回、色々な場所=GlobalIPから攻撃が飛んできているのもそのためであり、一定期間でアクセス元が変わってしまい捕まえるのが大変な状況になります。(また、被害者が加害者になってしまう構図も問題です)

以下はRTX1200でDDos攻撃を防ぐ目的で調査した際に判明したことを覚書しておきます。

DNSサーバーで有名なBIND(LINUX)はローカルIPからの問い合わせのみ再帰的な問合せに応答し、外部からの問い合わせには応答しない設定が出来ますので、DMZ内などに1台置くことでセキュリティ対策と保持Domainサーバーの2機能を賄うことが可能となっています。

一方、ActiveDirectryに対応する関係でWindows DNSサーバーを使用している会社さんも結構います。WindowsのDNSサーバーはローカルIPからの問い合わせと外部からの問い合わせに対する切り替え機能がないので、再帰的な問合せに対し応答するかしないかの2つしか設定できないので、社内に上位DNS情報のキャッシュサーバーを置きたい且つ、今まで通り保持Domainは社内のDNSサーバーを使いたいといった場合、セキュリティーの関係上、DMZに外用DNSサーバー、ローカルに内用DNSサーバーと2台立てることが必要となります。

プロバイダーが公開しているDNSを上位指定することでキャッシュサーバーを立てなくても解決できますが、多数のクライアントがある時、引っ越しなどの時は大変になりますね。(そこまで考えなくても良いかもしれませんが。。。)

雑学でした。。。

Read more
ApacheLinux日記

CentOS6.4 Apache 2.4.4 SSL 本番環境コピーでエラーとなる

1 Mins read

本番環境からconf系ファイルをコピーして使用できるよう環境構築時に嵌ったので覚書!

コピーしてきてapacheが起動しない、confテストはOK

error_logに以下の記載がある

AH02311: Fatal error initialising mod_ssl,

ssl用のアクセスログを見ると。。。

AH02204: Init: Pass phrase incorrect for key of localhost.local:443
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_EX_D2I:nested asn1 error (Type=RSA)
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_EX_D2I:nested asn1 error (Type=PKCS8_PRIV_KEY_INFO)

「Init: Pass phrase incorrect」とはSSL用の起動時passがないと言っている。。。はて?

決められた場所にpasswordファイルがあり、「SSLPassPhraseDialog exec:」のpassが間違っているのかと確認する。。。あってる。。。はて?

1時間ほど苦悶しながら調べる。。。あっ!?コピーしたから実行権限がなくなっているんだ!そう、このファイル内だけbshellが記載してあるんだ。。。とほほ、basic認証のpasswordファイルなどは関係ないのに。。。(すでに言い訳、笑)

Read more