Skip to main content

ID4175–The issuer of the security token was not recognized by the IssuerNameRegistry

Yesterday I worked in close collaboration with one of my clients to renew the certificates on their ADFS server. Of course this wouldn't be an interesting post if nothing went wrong and there was nothing to learn.

Changing the certificate is quite easy. First upload the certificate to your ADFS instance through the ADFS Management UI:

  • Open Server Manager
  • Click on “Tools”. Select “AD FS Management” from the menu.
  • Expand “Service” node and click on “Certificates”.
  • Click on “Set Service Communication Certificate” on the right side.



Now you can activate this certificate using the following command:

Set-AdfsSslCertificate -Thumbprint {thumbprint}

That’s the easy part. So where did we get into trouble?

After changing the certificate, some of our .NET applications started to fail with the following error message:

ID4175: The issuer of the security token was not recognized by the IssuerNameRegistry. To accept security tokens from this issuer, configure the IssuerNameRegistry to return a valid name for this issuer.

Let me explain why this happened. As part of our older .NET (4.8) applications the related ADFS configuration is added directly inside the web.config. Among the information we provide in the web.config is the list of allowed issuername registries:

By changing the certificate the corresponding thumbprint has changed as well. As a consequence the original configuration is no longer valid.

Fixing this is easy, just update the thumbprint inside the configuration.

But is there a better way so that we can avoid to do this change in the future when we have to renew our certificates again?

Federation metadata

The answer can be found in ‘Federation metadata’. ADFS (and other STS products) publishes a federation metadata document on a federation metadata endpoint. This metadata document format is described in the Web Services Federation Language (WS-Federation) Version 1.2, which extends Metadata for the OASIS Security Assertion Markup Language (SAML) v2.0.

It contains (at least) the following information:

  • Entity ID
  • Token signing certificates
  • WS-Federation endpoint URL
  • SAML endpoint URL

The good news is that our application logic can automatically read this information avoiding the need to store all this information directly in our web.config. So instead of using the built-in ConfigurationBasedIssuerNameRegistry that reads the issuer information from the web.config, we create our own instance that parses the federation metadata.

A solution was created by Brock Allen in Thinktecture.IdentityModel but this library is no longer maintained.

Here is a copy of the relevant code:

More information

Obtain and configure token signing and token decryption certificates for AD FS | Microsoft Learn

Dynamic issuer name registry direct from STS federation metadata with Thinktecture IdentityModel | brockallen

Popular posts from this blog

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.

Podman– Command execution failed with exit code 125

After updating WSL on one of the developer machines, Podman failed to work. When we took a look through Podman Desktop, we noticed that Podman had stopped running and returned the following error message: Error: Command execution failed with exit code 125 Here are the steps we tried to fix the issue: We started by running podman info to get some extra details on what could be wrong: >podman info OS: windows/amd64 provider: wsl version: 5.3.1 Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:2655: connectex: No connection could be made because the target machine actively refused it. That makes sense as the podman VM was not running. Let’s check the VM: >podman machine list NAME         ...

Cleaner switch expressions with pattern matching in C#

Ever find yourself mapping multiple string values to the same result? Being a C# developer for a long time, I sometimes forget that the C# has evolved so I still dare to chain case labels or reach for a dictionary. Of course with pattern matching this is no longer necessary. With pattern matching, you can express things inline, declaratively, and with zero repetition. A small example I was working on a small script that should invoke different actions depending on the environment. As our developers were using different variations for the same environment e.g.  "tst" alongside "test" , "prd" alongside "prod" .  We asked to streamline this a long time ago, but as these things happen, we still see variations in the wild. This brought me to the following code that is a perfect example for pattern matching: The or keyword here is a logical pattern combinator , not a boolean operator. It matches if either of the specified pattern...