splitcertificateapple-push-notificationsfastlanepem

How do I split a pem file?


So Fastlane pem generates a .pem file that includes both the certificate and the key. The system I need to upload it to takes two .pem files, one with the certificate and one with the key. It's trivial to manually split the file with a text editor, but is there a good command for splitting it in an automated fashion?


Solution

  • I did find a command to split the file into its two parts:

    csplit $pemfile '/^-----BEGIN RSA PRIVATE KEY-----$/'
    

    This leaves you with two files: xx00 containing the certificate and xx01 containing the key. Then all you need is a couple of mv commands to rename the files to something more appropriate.