Skip to content

Instantly share code, notes, and snippets.

@mancj
Last active May 14, 2024 12:57
Show Gist options
  • Save mancj/74b4606b8e3b72d68b2727f7fdb32166 to your computer and use it in GitHub Desktop.
Save mancj/74b4606b8e3b72d68b2727f7fdb32166 to your computer and use it in GitHub Desktop.
Bitrise p12 certificate generation

Connect to Bitrise

Connect Bitrise with "Rebuild with Remote Access" button

Local: Set Bitrise Variables

bash:

set BITRISE_PORT = 3.tcp.ngrok.io
set BITRISE_HOST = 21784
set BITRISE_PASSWORD = password

fish shell:

set BITRISE_PORT = 3.tcp.ngrok.io
set BITRISE_HOST = 21784
set BITRISE_PASSWORD = password

Note: Replace values, use URL and PORT from the command provided by Bitrise: ssh -o StrictHostKeyChecking=no vagrant@1.tcp.ngrok.io -p 29758 In this example 1.tcp.ngrok.io will be the BITRISE_HOST and 29758 it is the BITRISE_PORT

![[Frame 1 1.jpg]]

Remote: Run following commands on Bitrise machine:

mkdir cert; cd cert; \
openssl genrsa -out bitrise.key 2048; \
openssl req -new -key bitrise.key -out CSR.csr



Local: Now on local machine download generated CSR file:

rm -rf ~/Downloads/bitrise-cert
mkdir ~/Downloads/bitrise-cert; \
cd ~/Downloads/bitrise-cert; \

sshpass -p "$BITRISE_PASSWORD" scp -o StrictHostKeyChecking=no -P $BITRISE_PORT vagrant@$BITRISE_HOST:/Users/vagrant/cert/CSR.csr ~/Downloads/bitrise-cert/CSR.csr



Local: Create certificates in Apple Developer

Open Apple Developer Certificates page and create Development and Distribution certificates using CSR.csr file that is just downloaded ~/Downloads/bitrise-cert/ on your computer

Download .cer files from the Apple Developer, and place them in ~/Downloads/bitrise-cert folder.

Now run this command to upload those certificates to the Bitrise Remote machine

sshpass -p "$BITRISE_PASSWORD" scp -o StrictHostKeyChecking=no -P $BITRISE_PORT ~/Downloads/bitrise-cert/development.cer vagrant@$BITRISE_HOST:/Users/vagrant/cert/development.cer; \

sshpass -p "$BITRISE_PASSWORD" scp -o StrictHostKeyChecking=no -P $BITRISE_PORT ~/Downloads/bitrise-cert/distribution.cer vagrant@$BITRISE_HOST:/Users/vagrant/cert/distribution.cer



Remote: Generate .p12 cerfiticates

openssl pkcs12 -export -out distribution.p12 -inkey bitrise.key -in distribution.cer; \

openssl pkcs12 -export -out development.p12 -inkey bitrise.key -in development.cer; 



Local: Download this two p12 certificates to your local machine

sshpass -p "$BITRISE_PASSWORD" scp -o StrictHostKeyChecking=no -P $BITRISE_PORT vagrant@$BITRISE_HOST:/Users/vagrant/cert/development.p12 ~/Downloads/bitrise-cert/development.p12; \

sshpass -p "$BITRISE_PASSWORD" scp -o StrictHostKeyChecking=no -P $BITRISE_PORT vagrant@$BITRISE_HOST:/Users/vagrant/cert/distribution.p12 ~/Downloads/bitrise-cert/distribution.p12; \

open .



Done 👍

Now you can find .p12 certificates in your ~/Downloads/bitrise-cert folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment