Skip to content

Instantly share code, notes, and snippets.

@fernandezjose
Forked from mrcunninghamz/SelfSignedCert.md
Created December 7, 2021 23:13
Show Gist options
  • Save fernandezjose/c63ff9af6f4bef03b515480a322d3f47 to your computer and use it in GitHub Desktop.
Save fernandezjose/c63ff9af6f4bef03b515480a322d3f47 to your computer and use it in GitHub Desktop.
Creating a self signed certificate in a pfx format on a mac.

Create Self Signed Certificate

Introduction

Every now and then I need to create a self signed certificate in azure for something. In my particular case its Azure B2C. I am using a mac so its not simply just running something like

New-SelfSignedCertificate `
    -KeyExportPolicy Exportable `
    -Subject "CN=yourappname.yourtenant.onmicrosoft.com" `
    -KeyAlgorithm RSA `
    -KeyLength 2048 `
    -KeyUsage DigitalSignature `
    -NotAfter (Get-Date).AddMonths(12) `
    -CertStoreLocation "Cert:\CurrentUser\My"

Procedure

Create Cert

  • Create a key

    • openssl genrsa -out key.pem 2048
  • Create certifcate signin request

    • openssl req -new -sha256 -key key.pem -out csr.csr
    • enter whatever information you wish, good practice to include a password
  • Create certificate

    • openssl req -x509 -sha256 -days 365 -key key.pem -in csr.csr -out certificate.pem

Convert to .pfx file

openssl pkcs12 -export -out samlIdpCert.pfx -inkey key.pem -in certificate.pem

References

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