13
12

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

APNSのpemファイル作成用のシェル関数

Posted at

APNSのための証明書作成が毎回手間で、しかもミスが起こりやすかったので、関数にした。
といっても作業をまとめたぐらい。

function createApnsPem() {
    if [ $# != 2 ]; then
        echo "ArgumentError: wrong number of arguments ($# for 2)"
        echo '  arg1={certificate file name}, arg2={key file name}'
    else
        openssl pkcs12 -clcerts -nokeys -out apns-cert.pem -in $1
        openssl pkcs12 -nocerts -out apns-key.pem -in $2
        openssl rsa -in apns-key.pem -out apns-key-noenc.pem
        cat apns-cert.pem apns-key-noenc.pem > apns.pem
        rm apns-cert.pem apns-key-noenc.pem apns-key.pem
    fi
}

第一引数に証明書のファイル名、第二引数に秘密鍵のファイル名を渡せば、最終的なpemファイルが生成される。(途中でパスワードを入力するのみ)

$ createApnsPem cert.p12 key.p12
13
12
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
13
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?