Advanced SAML Security: One App per certificate

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Welcome Idira to LIVEcommunity!

Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.

Meet Idira

Workforce Identity Articles
10 min read
L4 Transporter
No ratings
Security in SAML is ultimately a trust relationship that is built around the use of a Certificate or multiple Certificates. This article will instruct the Identity Administrator on how to generate a unique certificate so that each application has its own certificate instead of using a single certificate for the tenant.

The private key of your default issued signing certificate is not visible to you as the administrator through the GUI or through API access. The expiration of this default certificate is also 10 years from account creation and so you have a very large window before you are forced to update service providers. 

Author: Kevin Creason

Steps

Why? 

So why would you want to go through these steps of creating and using multiple signing certificates? There are many reasons, and they can be summarized along these lines – 

  • Unique certs can provide Trust and Assurance to both parties. By generating a unique certificate per application, we can provide the security conscious Identity administrator and the Service Provider administrator with a higher level of assurance at trusting the SAML relationship. The certificate used is for one relationship, one service provider. 

  • Revalidation of Trust relationships – using unique certificates and unique expirations can be used as a means of revalidating a service provider relationship by involving administrative actions to change the certificate. Do you plan to retire this application next year and replace it with app Xyz? Set the expiration to 12 months, you will guarantee admins need to review and reconfigure. 

  • Timing of Expirations – SSL certificates used for websites are now mandated to expire at 13 months so that we have greater trust that the site we are visiting is maintained and is who they were. These same controls do not necessarily apply to the signing certificates for SAML trust (hence the 10-year initial certificate), but it is possible that these controls may be important to an organization. 

  • Balancing Replacement cycle – when a certificate is expiring, whether it is 10 years or 1 year after being generated, the replacement must be coordinated between IDP and SP at the same time or the assertion will not be valid. If you are generating a new certificate for each application as you start that application, you will be spacing out the replacement window using the same gap of time as you have added applications. This is often a good deal more convenient than attempting to complete hundreds of apps in a brief period because they were using a single certificate that is expiring. 

 

Before we jump into the How, let us cover a little background information first. 

The certificate is used to sign the SAML Assertion so that the Service Provider can validate the data and trust that it came from your Identity Provider (Idira Identity). The Service Provider may not require their own certificate to validate the signature, but if encryption has been enabled, they will need their own unique certificate. 

There are two fundamental truths about certificates and keys that must always be kept forefront of your mind when dealing with certificates-- 

  1. The certificate can be visible or shared publicly. For this reason, it is sometimes referred to as the Public Certificate. 

  1. A key is another half of the certificate and should always be private, never shared. For this reason, it is sometimes referred to as a private key. If someone were to get access to the private key, they would be able to use the public certificate as if they were the original holder of the certificate, there would be nothing to indicate anything to the contrary. 

A third item which is up for debate among some circles is the Certificate Authority. The prevailing consensus is that since SAML signing (and encryption) is not required to be trusted by the client browser that we can use self-signed certificates for signing, and not be required to use a trusted Certificate Authority. This can avoid a monetary and time cost in dealing with trusted CAs and allow the administrator to create unique certificates per application—unique private key, unique signing authority, and unique certificate. This article will focus on using self-signing, but some steps will be valid for those parties using a trusted CA. 

When something is being digitally signed, the signing entity is using their private key and public certificate and generating a hash of the object being signed. Anyone can then obtain the public certificate and validate this signature was completed by someone with the private and non-public key. 

Alternatively, if we want to restrict the contents so that only the intended audience can see the data, we must enable encryption. To do this we not only need our own private key and public certificate, but we also require a public certificate from the intended or target consumer (service provider). This means that the target consumer must have their private key, public certificate, and a copy of our public certificate. No one's private key is ever exchanged, the private key should remain protected and never shared, only public certificates are exchanged. 

The encryption level is rarely utilized in SAML relationships. The SAML conversation traverses through the client browser and should be restricted to TLS 1.2 or better HTTPS connections. This controls and limits prying eyes, but at times the additional level of protection provided by encryption may be desired. 

How 

The Idira Identity administrator UI does not yet provide you with the means to generate a new signing certificate in the browser. This feature is planned, but until this feature is released you must generate a certificate and key pair using external means and upload to Identity. 

This external generation and uploading are the moment where you are most vulnerable! Protect the private key you generated with the highest security you can, and securely destroy it after you have uploaded it.  

"Destroy it?", I can hear you say. 

Yes! What better security than to completely delete the record of the private key once it has been loaded into your secure Idira tenant. You will not need this private key ever again. Only Idira needs the key to sign or encrypt the data for the SAML Assertion. 

We will provide two mechanisms that can be used to generate the cert pair suitable for uploading. You need only do one of these sections that is easiest for you to use. 

OpenSSL (Any OS) 

You can use OpenSSL on any platform and simply copy these commands to a suitable command line interface. A MacOS device and Linux system will likely already have this utility installed and they should execute and provide the output file needed for uploading to Idira Identity. 

The following commands will generate a new self-signed certificate, key, and then a PFX file containing both. The PFX will have no password running this command. Destroy the key file and the unprotected PFX immediately after uploading.  

Also, note, the name used in the "SAMLNAME" is used for the certificate name and the output file without requiring any CLI conversion utilities which may be OS dependent, so avoid unsafe filename characters. This keeps the example short and sweet and extremely generic, but this could be easily scripted for your platform to give you more versatility, similar to the PowerShell example in this doc. 

SAMLNAME="SAML-App-XYZ_20240130" 
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout $SAMLNAME.key -out $SAMLNAME.crt -subj "/CN=$SAMLNAME" 
openssl pkcs12 -export -inkey $SAMLNAME.key -in $SAMLNAME.crt -out $SAMLNAME.pfx -name "$SAMLNAME " -password pass: 

The key and certificate options you may interested in tweaking with each run, besides the SAMLNAME variable are as follows: 

  • "rsa:4096" – this is both the key type and the key length. You may have some service providers that cannot handle 4096, so the highest you could go would be only 2048. 

  • "-sha256" – this is the certificate algorithm; you may have some Service Providers that may only support SHA1 

  • "-days 3650" – this is the number of days until expiration. 

Do not forget to destroy your unprotected private key and PFX file after you have uploaded it. 

 

PowerShell (Windows) 

Your Windows device should have PowerShell available. The commands do not require elevated privilege, but it is possible that unique controls may block either PowerShell or some modules from you. Consult with the relevant team at your organization if this is the case. 

The PowerShell script below will generate a self-signed certificate into your local personal cert store on the Windows system. It will then export the key and certificate into a PKCS12 PFX file that is password protected and can be uploaded into Idira Identity. 

Both the cert-key pair in the keystore and the PFX file have some security built in but are still considered weak security. You should consider deleting both objects after the PFX file has been uploaded to Identity. The PFX file will be located in the directory where you run the script. 

Script 

<#
.SYNOPSIS
Self Signed Certificate Automator

.DESCRIPTION
use CLI options to specify options or it will take defaults

.PARAMETER debug
Set debug level for extra info

.PARAMETER months
How many months cert will be good for, default 24

.PARAMETER name
The name and subject of the cert

.PARAMETER keylength
The private key length, 4096 is better, 2048 common

.PARAMETER keyalg
The private key algorhithm, RSA default

.PARAMETER hashalg
The hashing algorithm, SHA256 recommended, sha1 is sometimes needed but less secure.

.PARAMETER exppass
The exported file password


.EXAMPLE
PS> cert-automator.ps1 -debug 2 -name "SAML App Xyz" -months 36 -keylength 4096 -exppass "3xp000rtP@ssw0rd"

PS> cert-automator.ps1 -debug 2 -name "SAML App Pdq"

PS> cert-automator.ps1 -debug 2 

#>

# This is where we define the command line defaults. These can be updated if you do not want to specify them at run time
param (
    [int]$months = 24,
    [int]$keylength = 4096,
    [string]$name = "saml-cert",
    [string]$exppass = "export-password",
    [string]$keyalg ="RSA",
    [string]$hashalg = "SHA256",
    [int]$debug = "3"
 )

 # Function to clean up the saml cert name to use for the output file
 Function NameToFileName {
  param(
    [Parameter(Mandatory=$true,
      Position=0,
      ValueFromPipeline=$true,
      ValueFromPipelineByPropertyName=$true)]
    [String]$Name
  )
  $invalidChars = [IO.Path]::GetInvalidFileNameChars() -join ''
  $invalidChars = $invalidChars+" "+'%'+'$'+'@'+','+'.'+"'"
  $re = "[{0}]" -f [RegEx]::Escape($invalidChars)
  return ($Name -replace $re)
}

# Default Values for the actual certificate
 $params = @{ 
   Type = 'Custom'
    Subject = $name  
    KeyAlgorithm = $keyalg
    KeyLength = $keylength
    HashAlgorithm = $hashalg
    SmimeCapabilities = $true
    CertStoreLocation = 'Cert:\CurrentUser\My'
    NotAfter = (Get-Date).AddMonths($months)
}

$NewCert = New-SelfsignedCertificate @params
$output = NameToFileName($name)
$PFXpass = ConvertTo-SecureString -String $exppass -Force -AsPlainText
Export-PfxCertificate -Cert $NewCert -Filepath ".\$output.pfx" -Password $PFXpass

 

Running the Script 

The script is designed so that you can run it from the command line and specify unique options each time but otherwise use some pre-defined options. You can also use the PowerShell "get-help" option to see execution tips: 

ka3Ht0000009XMnIAM__eid=ka3Ht0000009XMn&feoid=00N2J000009R3kv&refid=0EMHt000006jvHq.png 

Alternatively, you can load the script into the ISE, edit param lines for each run, and click the Play icon to generate a unique certificate content. 

ka3Ht0000009XMnIAM__eid=ka3Ht0000009XMn&feoid=00N2J000009R3kv&refid=0EMHt000006jvHv.png 

 

After… and Beyond 

After you have completed the steps of generating a new private key, using it for a self-signed certificate, and combined it into a PKCS12/PFX file for uploading… now what? 

At this point you are ready to use the Idira Identity standard Administrator interface fully documented here. You will use the "Add a signing certificate" option, in addition to the other management steps. This upload step may be skipped if you prefer to upload it during the web app configuration in the Manual Configuration. 

A suggested order of operations could be, but is not strictly necessary to follow this order: 

  1. Add new Web App in Identity 

  1. Configure Web App in Identity and on the Trust "Identity Provider Configuration" page you can select the desired previously uploaded certificate, or use option "Upload New Signing Certificate" (and then delete the PFX) 

  1. Exchange the public certificate and SAML metadata with Service Provider 

  1. Relax, sip your coffee or other beverage of choice, and continue to monitor the security of your organization 

Rate this article:
  • 996 Views
  • 0 comments
  • 0 Likes
Article Dashboard
Version history
Last Updated:
‎11-05-2026 11:59 AM
Updated by: