This page describes the process of certificate rollover for Shibboleth Identity Providers. The procedure described below allows replacing certificates without any service disruptions.

In SWAMID default installation we have both an Encryption and a Signing certificate.

Step 0 : Create new certificate

$ADFSDnsName = "[ADFS DNS Name]"
# Encryption Certificate
$encryptionCertificate = New-SelfSignedCertificate -CertStoreLocation "cert:\LocalMachine\My" -DnsName "encryption.$ADFSDnsName" -KeyExportPolicy Exportable -KeyLength 4096 -NotAfter (Get-Date).AddYears(10) -KeySpec KeyExchange

# Signing Certificate
$signingCertificate = New-SelfSignedCertificate -CertStoreLocation "cert:\LocalMachine\My" -DnsName "signing.$ADFSDnsName" -KeyExportPolicy Exportable -KeyLength 4096 -NotAfter (Get-Date).AddYears(10) -KeySpec KeyExchange
Get-AdfsProperties | Select AutoCertificateRollover
Set-AdfsProperties -AutoCertificateRollover $false

Step 1 : Export certificates and import on all ADFS servers in the farm

# Encryption Certificate
$encryptionPassword = Read-Host "Type a secure password for the encryption PFX file" -AsSecureString
Export-PfxCertificate -Cert $encryptionCertificate -FilePath ("C:\{0}.pfx" -f $ADFSDnsName -Password $password

# Signing Certificate
$signingPassword = Read-Host "Type a secure password for the signing PFX file" -AsSecureString
Export-PfxCertificate -Cert $signingCertificate -FilePath ("C:\{0}.pfx" -f $ADFSDnsName -Password $password
$ADFSDnsName = "[ADFS DNS Name]"

# Encryption Certificate
$encryptionPassword = Read-Host "Type the previous password for the encryption PFX file" -AsSecureString
Import-PfxCertificate -FilePath 'C:\encryption.ADFS DNS Name.pfx' -Exportable:$true -Password $encryptionPassword -CertStoreLocation "cert:\LocalMachine\My"

# Signing Certificate
$signingPassword = Read-Host "Type the password for the signing PFX file" -AsSecureString
Import-PfxCertificate -FilePath 'C:\signing.ADFS DNS Name.pfx' -Exportable:$true -Password $signingPassword -CertStoreLocation "cert:\LocalMachine\My"



Step 1 : Add Certificates to ADFS

Add-AdfsCertificate -CertificateType "Token-Signing" -Thumbprint "thumbprint of signing cert" 
Add-AdfsCertificate -CertificateType "Token-Decrypting" -Thumbprint "thumbprint of decrypting cert" 

Step 2 : Upload new Metadata

ADFS normally publish new signing-certs in the step and rolls the encryption-cert in step 4!!!

Step 3 : Certificate rollover 

Automatic rollover

When does this happen? In the Get-AdfsProperties command, you can check the value for CertificateCriticalThreshold.

The default setting is 2 and it means that ADFS will switch the certificates two days before their expiration date weather you want it to or not.

The next parameter of interest is CertificatePromotionThreshold, the default value of 5 means the old certificate will be present as a secondary certificate for five days after rollover.

Manual rollover

This can be done in the console by right clicking on the certificate and select "Set as primary" or by powershell

Set-AdfsCertificate -CertificateType "Token-Decrypting/Token-Signing" -Thumbprint "thumbprint of cert" -IsPrimary

Step 4 : Upload new Metadata again

ADFS should now have removed the old signing cert in XML and replaced the encryption cert in https://adfs.example.com/federationmetadata/2007-06/federationmetadata.xml

Step 5 : Disable / remove key from software. 

Remove old certificates from console or with powershell

Remove-AdfsCertificate -CertificateType "Token-Signing or Token-Decrypting" -Thumbprint "thumbprint"