author | ms.service | ms.subservice | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|
msmimart |
active-directory-b2c |
B2C |
include |
01/27/2021 |
mimart |
If you don't already have a certificate, you can use a self-signed certificate. A self-signed certificate is a security certificate that is not signed by a certificate authority (CA) and doesn't provide the security guarantees of a certificate signed by a CA.
On Windows, use PowerShell's New-SelfSignedCertificate cmdlet to generate a certificate.
-
Execute this PowerShell command to generate a self-signed certificate. Modify the
-Subject
argument as appropriate for your application and Azure AD B2C tenant name. You can also adjust the-NotAfter
date to specify a different expiration for the certificate.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"
-
Open Manage user certificates > Current User > Personal > Certificates > yourappname.yourtenant.onmicrosoft.com.
-
Select the certificate, and then select Action > All Tasks > Export.
-
Select Yes > Next > Yes, export the private key > Next.
-
Accept the defaults for Export File Format.
-
Provide a password for the certificate.
For Azure AD B2C to accept the .pfx file password, the password must be encrypted with the TripleDES-SHA1 option in Windows Certificate Store Export utility as opposed to AES256-SHA256.
On macOS, use Certificate Assistant in Keychain Access to generate a certificate.
- Follow the instructions for how to create self-signed certificates in Keychain Access on Mac.
- In the Keychain Access app on your Mac, select the certificate you created.
- Choose File > Export Items.
- Select a file name to save your certificate. For example, self-signed-certificate.p12.
- For the File Format, select Personal Information Exchange (.p12).
- Select Save.
- Enter a Password, and then Verify the password.
- Replace the file extension to
.pfx
. For example, self-signed-certificate.pfx.