1
0

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 1 year has passed since last update.

imap-login: Error: Failed to initialize SSL server context

Last updated at Posted at 2024-02-05

imap-login: Error: Failed to initialize SSL server context

/var/log/maillogに以下のようなログが記録されていました。

Feb  4 00:01:03 sub0000529529 dovecot[2533359]: imap-login: Error: Failed to initialize SSL server context: Can't load DH parameters (ssl_dh setting): error:1408518A:SSLroutines:ssl3_ctx_ctrl:dh key too small: user=<>, rip=***.***.***.***, lip=***.***.***.***, session=<LApYf3sQVOCnXpIz>

意図しないログ出力でしたので対処いたしました。

環境

AlmaLinux release 8.9

対処

使用していないdovecotサービスが起動されていたので、サービスを停止しました。

# systemctl stop dovecot.service
# systemctl disable dovecot.service

dovecotサービスは使用しないので停止しているつもりでしたが、起動していました。

詳細

下記ログからIMAPが動いていると思われました。

Feb  4 00:01:03 sub0000529529 dovecot[2533359]: imap-login: Error: Failed to initialize SSL server context: Can't load DH parameters (ssl_dh setting): error:1408518A:SSLroutines:ssl3_ctx_ctrl:dh key too small: user=<>, rip=***.***.***.***, lip=***.***.***.***, session=<LApYf3sQVOCnXpIz>

IMAPを動かしているつもりはなかったので、IMAPが待ち受けているポートを確認しました。

$ netstat -nap | grep LISTEN
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
(中略)    
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      -      
tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN      -      
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      -              
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      -              
(以下略)

メールサーバーで使用されるポートが開いています。

systemctl list-units --type=serviceで起動しているメールサーバーのサービス名を調べようとしましたが
名前に見当がつきませんでした。※自分はメールサーバーを運用した経験がありません。
netstatコマンドを使用し993番ポートで待ち受けているサービスを確認します。

$ sudo netstat -tulnp | grep :993
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      2533355/dovecot 
tcp6       0      0 :::993                  :::*                    LISTEN      2533355/dovecot 

dovecotというサービスだと分かりましたので、dovecotを停止します。

# systemctl stop dovecot.service
# systemctl disable dovecot.service

なぜdovecotを停止していなかったのか?の推測

サーバー構築時にdovecotをdisableにしていなかったと思われます。
dovecotという名前がまさかメールサーバーだとは思わなかったのでしょう。
おそらくサーバー動作に必要なサービスだと思って停止しなかったのだと思います。
次にサーバーを構築する場合はサービスを確認するようにせねばならないと思いましたが、systemctl list-units --type=serviceの出力が多いので、大変…
netstat -tulnpで余計なポートが開いていないかを確認するのでもいいかな…と思いました。

疑問

このサーバーは必要なポートしか開放していません。
しかし、dovecotに接続できてしまっていました。
dovecotを再度起動し、外部からポート993に接続できないことを確認しました。

$ nmap -sT -p993 ***.***.***.***
(中略)
PORT    STATE    SERVICE
993/tcp filtered imaps

結局、なぜ外部からIMAPに接続できたのか分かりませんでした。
ChatGPT4に尋ねたのですがやはり見当がつきませんでした。

image.png

たとえサービスを誤って起動していてもnftableで必要なポートしか開放していないのでOK、と思っていたのですが、その前提が崩れて、他になんの設定が誤っているのだ…と悩んでいます。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?