Creating .pem file for APNS?

后端 未结 11 2224
野的像风
野的像风 2020-11-27 08:59

How do I create a .pem file to be stored in the hosting server for APN payload data?

11条回答
  •  迷失自我
    2020-11-27 09:39

    I never remember the openssl command needed to create a .pem file, so I made this bash script to simplify the process:

    #!/bin/bash
    if [ $# -eq 2 ]
    then
        echo "Signing $1..."
    
        if ! openssl pkcs12 -in $1 -out $2 -nodes -clcerts; then
            echo "Error signing certificate."
        else
            echo "Certificate created successfully: $2"
        fi
    else
        if [ $# -gt 2 ]
        then
            echo "Too many arguments"
            echo "Syntax: $0  "
        else
            echo "Missing arguments"
            echo "Syntax: $0  "
        fi
    fi
    

    Name it, for example, signpem.sh and save it on your user's folder (/Users/?). After creating the file, do a chmod +x signpem.sh to make it executable and then you can run:

    ~/signpem myCertificate.p12 myCertificate.pem

    And myCertificate.pem will be created.

提交回复
热议问题