Skip to content

Instantly share code, notes, and snippets.

@hmarcelodn
Created November 5, 2020 18:22
Show Gist options
  • Save hmarcelodn/65a343923e25065cf6644ad821dd6711 to your computer and use it in GitHub Desktop.
Save hmarcelodn/65a343923e25065cf6644ad821dd6711 to your computer and use it in GitHub Desktop.
P12 Generator
#!/bin/bash
USERNAME=marcelo.delnegro
NAME=cert.staging.na01.northcountryfire.demandware.net
DAYS=36500
# 0 - Navigate to P12
cd ./STG-2FA-northcountryfire-00457696/
# 1 - Generate Request
# openssl req -new -sha256 -newkey rsa:2048 -nodes -out <user>.req -keyout <user>.key
# ======================================================================
# Country Name (2 letter code) [AU]: US
# State or Province Name (full name) [Some-State]: Massachusetts
# Locality Name (city) []:
# Organization Name (company) [Internet Widgits Pty Ltd]: B2C Commerce
# Organizational Unit Name (section) []: Customer Services
# Common Name (YOUR name) []: John Smith
# Email Address []: jsmith@salesforce.com
# Enter the following 'extra' attributes
# to be sent with your certificate request
# A challenge password []:
# An optional company name []:
# ======================================================================
clear
ls
openssl req -new -sha256 -newkey rsa:2048 -nodes -out ${USERNAME}.req -keyout ${USERNAME}.key
# 2 - Sign the certificate request ( <user>.req) with your certificate
# ======================================================================
# openssl x509 -CA cert.staging.web.customer.demandware.net_01.crt -CAkey cert.staging.web.customer.demandware.net_01.key
# -CAserial cert.staging.web.customer.demandware.net.srl -req -in jsmith.req -out jsmith.pem -days 10
# ======================================================================
clear
openssl x509 -CA ${NAME}_01.crt -CAkey ${NAME}_01.key -CAserial ${NAME}.srl -req -in ${USERNAME}.req -out ${USERNAME}.pem -days ${DAYS}
# 3 - Export the certificate and client information to pkcs12 format.
# ======================================================================
# openssl pkcs12 -export -in jsmith.pem -inkey jsmith.key -certfile cert.staging.web.customer.demandware.net_01.crt -name "jsmith" -out jsmith.p12
# ======================================================================
# The system prompts for an export password for the file.
clear
openssl pkcs12 -export -in ${USERNAME}.pem -inkey ${USERNAME}.key -certfile ${NAME}_01.crt -name "${USERNAME}" -out ${USERNAME}.p12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment