Skip to content

Instantly share code, notes, and snippets.

@thara
Created July 25, 2014 17:37
Show Gist options
  • Select an option

  • Save thara/0637ba128dee2d193f9a to your computer and use it in GitHub Desktop.

Select an option

Save thara/0637ba128dee2d193f9a to your computer and use it in GitHub Desktop.
SMTP Auth + TLSの設定をローカルマシンで動作確認する ref: http://qiita.com/t_hara/items/3b42d8ae3e84f8d89d65
$ perl -MMIME::Base64 -e 'print encode_base64(
> "username\0group\0password");'
** base64エンコードされた文字列A ** <- あとで使う
$ telnet mail.example.com smtp
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 mail.example.com ESMTP unknown
EHLO example.com <- 1 SMTPで拡張している設定を表示
250-mail.example.com
250-PIPELINING
250-SIZE 1024000
250-VRFY
250-ETRN
250-AUTH LOGIN DIGEST-MD5 PLAIN CRAM-MD5
250-XVERP
250 8BITMIME
AUTH PLAIN ** base64エンコードされた文字列A ** <- 2 エンコード済認証情報入力
235 Authentication successful <- 3 認証成功
DONE
$ openssl s_client -connect 127.0.0.1:465
CONNECTED(00000003)
*略*
verify error:num=18:self signed certificate
verify return:1
*略*
verify return:1
---
Certificate chain
0 s:*略*
i:*略*
---
Server certificate
-----BEGIN CERTIFICATE-----
*略*
-----END CERTIFICATE-----
subject=*略*
issuer=*略*
---
No client certificate CA names sent
---
SSL handshake has read 1818 bytes and written 453 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1.2
Cipher : DHE-RSA-AES256-GCM-SHA384
Session-ID: *略*
Session-ID-ctx:
Master-Key: *略*
Key-Arg : None
Krb5 Principal: None
PSK identity: None
PSK identity hint: None
TLS session ticket lifetime hint: 3600 (seconds)
TLS session ticket:
*略*
Start Time: 1406306753
Timeout : 300 (sec)
Verify return code: 18 (self signed certificate)
---
220 mail.example.com ESMTP unknown
EHLO example.com <- 1 SMTPで拡張している設定を表示
250-mail.isuka.org
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH PLAIN ** base64エンコードされた文字列A ** <- 2 エンコード済認証情報入力
235 Authentication successful <- 3 認証成功
QUIT
DONE
$ telnet mail.example.com smtp
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 mail.example.com ESMTP unknown
EHLO example.com <- 1 SMTPで拡張している設定を表示
250-mail.example.com
250-PIPELINING
250-SIZE 1024000
250-VRFY
250-ETRN
250-AUTH LOGIN DIGEST-MD5 PLAIN CRAM-MD5
250-XVERP
250 8BITMIME
AUTH PLAIN ** base64エンコードされた文字列A ** <- 2 エンコード済認証情報入力
334 xxxxxxx
535 5.7.8 Error: authentication failed: authentication failure <- 3 認証失敗
$ perl -MMIME::Base64 -e 'print encode_base64("\0username\0password")'
** base64エンコードされた文字列B ** <- あとで使う。グループ無しに注意。
$ openssl s_client -starttls smtp -connect 127.0.0.1:587
CONNECTED(00000003)
*略*
verify error:num=18:self signed certificate
verify return:1
*略*
verify return:1
---
Certificate chain
0 s:*略*
i:*略*
---
Server certificate
-----BEGIN CERTIFICATE-----
*略*
-----END CERTIFICATE-----
subject=*略*
issuer=*略*
---
No client certificate CA names sent
---
SSL handshake has read 2009 bytes and written 488 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1.2
Cipher : DHE-RSA-AES256-GCM-SHA384
Session-ID: *略*
Session-ID-ctx:
Master-Key: *略*
Key-Arg : None
Krb5 Principal: None
PSK identity: None
PSK identity hint: None
TLS session ticket lifetime hint: 3600 (seconds)
TLS session ticket:
*略*
Start Time: 1406312201
Timeout : 300 (sec)
Verify return code: 18 (self signed certificate)
---
250 DSN
EHLO example.com <- 1 SMTPで拡張している設定を表示
250-mail.example.com
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH PLAIN ** base64エンコードされた文字列B ** <- 2 エンコード済認証情報入力
235 2.7.0 Authentication successful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment