Skip to content

HTTPS certificate exact match using Issuer's SimpleName instead of Certificate's #49062

@dan-olsen

Description

@dan-olsen

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have 2 certificates NAME and NAMEB (actual cert names changed for obvious reasons). I am trying to configure Kestrel to use the NAMEB cert but the NAME cert is always being chosen. These certs are not self-signed.

As part of #34582 the Microsoft.AspNetCore.Server.Kestrel.Https.CertificateLoader was changed to support exact subject name match but it appears the certificate's issuer SimpleName is being used instead of the certificate's SimpleName. The certificate.GetNameInfo(X509NameType.SimpleName, true) should be certificate.GetNameInfo(X509NameType.SimpleName, false)

It should be noted that the NAME cert expires after the NAMEB cert which is why it is being chosen as the the first found cert.

Expected Behavior

I would expect the exact match logic to work and the NAME cert is chosen.

Steps To Reproduce

Kestrel config:

"Kestrel": {
    "Endpoints": {
      "HttpsInlineCertStore": {
        "Url": "https://NAME:7286",
        "Certificate": {
          "Subject": "NAME",
          "Store": "MY",
          "Location": "LocalMachine"
        }
      }
    }
  }

With the following 2 certs in the cert store:

  • NAME
    • Expires after NAMEB
  • NAMEB

Exceptions (if any)

No response

.NET Version

7.0.304

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions