LoginSignup
1
0

More than 5 years have passed since last update.

[iOS]Push通知用の証明書と秘密鍵が有効かをopensslで確認する

Posted at

Apple Developerセンターから作成したpush通知用の署名つき証明書秘密鍵で、AppleのPush通知APIへhttpsリクエストできるかをopensslコマンドで確認が出来る。

-cert,-keyオプションのみで実行する.
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert dev_cert.pem -key dev_pkey.pem
実行結果.
+[master]
CONNECTED(00000006)
depth=1 C = US, O = "Entrust, Inc.", OU = See www.entrust.net/legal-terms, OU = "(c) 2012 Entrust, Inc. - for authorized use only", CN = Entrust Certification Authority - L1K
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/C=US/ST=California/L=Cupertino/O=Apple Inc./CN=gateway.sandbox.push.apple.com
   i:/C=US/O=Entrust, Inc./OU=See www.entrust.net/legal-terms/OU=(c) 2012 Entrust, Inc. - for authorized use only/CN=Entrust Certification Authority - L1K
 1 s:/C=US/O=Entrust, Inc./OU=See www.entrust.net/legal-terms/OU=(c) 2012 Entrust, Inc. - for authorized use only/CN=Entrust Certification Authority - L1K
   i:/O=Entrust.net/OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.)/OU=(c) 1999 Entrust.net Limited/CN=Entrust.net Certification Authority (2048)
---

認証局での証明書検証が出来なかったためverify error:num=20:unable to get local issuer certificateとエラーメッセージが出力されている模様。
これは-CAfileオプションで認証局の証明書パスを指定することにより解消できる。
opensslではブラウザのように認証局の証明書を取りに行かないので、手元にダウンロードし指定する必要がある。

-CAfileオプションも付けて実行する.
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert aps.pem -key app.pem -CAfile /Users/hoge/entrust_2048_ca.cer
実行結果.
CONNECTED(00000006)
depth=2 O = Entrust.net, OU = www.entrust.net/CPS_2048 incorp. by ref. (limits liab.), OU = (c) 1999 Entrust.net Limited, CN = Entrust.net Certification Authority (2048)
verify return:1
depth=1 C = US, O = "Entrust, Inc.", OU = See www.entrust.net/legal-terms, OU = "(c) 2012 Entrust, Inc. - for authorized use only", CN = Entrust Certification Authority - L1K
verify return:1
depth=0 C = US, ST = California, L = Cupertino, O = Apple Inc., CN = gateway.sandbox.push.apple.com
verify return:1
---
Certificate chain
 0 s:/C=US/ST=California/L=Cupertino/O=Apple Inc./CN=gateway.sandbox.push.apple.com
   i:/C=US/O=Entrust, Inc./OU=See www.entrust.net/legal-terms/OU=(c) 2012 Entrust, Inc. - for authorized use only/CN=Entrust Certification Authority - L1K
 1 s:/C=US/O=Entrust, Inc./OU=See www.entrust.net/legal-terms/OU=(c) 2012 Entrust, Inc. - for authorized use only/CN=Entrust Certification Authority - L1K
   i:/O=Entrust.net/OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.)/OU=(c) 1999 Entrust.net Limited/CN=Entrust.net Certification Authority (2048)
---

エラーが消えた。

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