Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to generate server certificate from root CA and preserve hierarchy #52

Open
darind opened this issue Nov 22, 2022 · 1 comment
Open

Comments

@darind
Copy link

darind commented Nov 22, 2022

I am trying to generate a X509 certificate from a root CA and use it as a server certificate. I tried the following from the demo:

var serviceProvider = new ServiceCollection()
    .AddCertificateManager()
    .BuildServiceProvider();

var createClientServerAuthCerts = serviceProvider.GetService<CreateCertificatesClientServerAuth>();

var rootCaL1 = createClientServerAuthCerts.NewRootCertificate(
    new DistinguishedName { CommonName = "root dev", Country = "IT" },
    new ValidityPeriod { ValidFrom = DateTime.UtcNow, ValidTo = DateTime.UtcNow.AddYears(10) },
    3,
    "localhost");

var intermediateCaL2 = createClientServerAuthCerts.NewIntermediateChainedCertificate(
    new DistinguishedName { CommonName = "intermediate dev", Country = "FR" },
    new ValidityPeriod { ValidFrom = DateTime.UtcNow, ValidTo = DateTime.UtcNow.AddYears(10) },
    2,
    "localhost",
    rootCaL1);

var serverL3 = createClientServerAuthCerts.NewServerChainedCertificate(
    new DistinguishedName { CommonName = "server", Country = "DE" },
    new ValidityPeriod { ValidFrom = DateTime.UtcNow, ValidTo = DateTime.UtcNow.AddYears(10) },
    "localhost",
    intermediateCaL2);

When I try to use the resulting leaf certificate (serverL3) on an HTTP server, I get the following certificate hierarchy:

image

Whereas what I am trying to achieve is the following:

image

Is this possible using AspNetCoreCertificates?

@darind darind changed the title Unable to generate server certificate from root CA Unable to generate server certificate from root CA and preserve hierarchy Nov 22, 2022
@White7292
Copy link

White7292 commented Nov 24, 2022

I believe I'm also running into the same issue? Although, chances are that I'm simply not using the library properly...

I'm trying to generate a chain of trust: which I can do with OpenSSL directly to get something like this:
image

But... when I try (a different chain) with the code- I don't get the chain:
image

The chain I'm expecting to have is: root > root-intermediate > tenant-X-intermediate > organization-X-intermediate > device-X-leaf certificate for Azure IoT Hub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants