Giter Site home page Giter Site logo

Full chain certificate about acme-ps HOT 8 CLOSED

pkisharp avatar pkisharp commented on July 22, 2024
Full chain certificate

from acme-ps.

Comments (8)

Gholie avatar Gholie commented on July 22, 2024 1

I solved this with the following snippet, it does sometimes build it in the wrong order though...:

# This certificate does not have the full chain, which might break some applications. Creating the full chain
    $tmpPfx = Get-PfxData -FilePath "$env:TEMP\$domain.pfx" -Password $password
    Export-PfxCertificate -PFXData $tmpPfx -FilePath "$env:TEMP\fullchain.pfx" -Password $password -ChainOption BuildChain

Not sure if it fits into this module, but it does fit into a script using it @glatzert

from acme-ps.

glatzert avatar glatzert commented on July 22, 2024 1

Version 1.2 will include the certificate chain during export.

from acme-ps.

glatzert avatar glatzert commented on July 22, 2024

LE will not include the chain automatically, so you have to download and combine it yourself (use openssl for that) - the Link is in the README.md file.
If you have any Idea, how I might automatically download the chain and include it into the exported cert, I'll most likely implement it, but as of now, I don't know how that would be done in .NET or PS.

from acme-ps.

glatzert avatar glatzert commented on July 22, 2024

As part of an example that might work.
It's important to mention, that the Export will only include the chain, if it's present in the Windows-Certificate store.
Nevertheless - it might be possible to set the -ChainOption in Export-AcmeCertificate, so it will be picked up, if available.

  • Invesitage -ChainOption in Export-AcmeCertificate

from acme-ps.

asifma avatar asifma commented on July 22, 2024

I solved this with the following snippet, it does sometimes build it in the wrong order though...:

# This certificate does not have the full chain, which might break some applications. Creating the full chain
    $tmpPfx = Get-PfxData -FilePath "$env:TEMP\$domain.pfx" -Password $password
    Export-PfxCertificate -PFXData $tmpPfx -FilePath "$env:TEMP\fullchain.pfx" -Password $password -ChainOption BuildChain

Not sure if it fits into this module, but it does fit into a script using it @glatzert

Thanks man!!! This helped me alot!!

from acme-ps.

alexzorin avatar alexzorin commented on July 22, 2024

LE will not include the chain automatically

Hi @glatzert, The Let's Encrypt ACME v2 server has always sent the full PEM-encoded certificate chain at the certificate URL.

This response should contain both the leaf and intermediate as an application/pem-certificate-chain:

https://github.com/PKISharp/ACMESharpCore-PowerShell/blob/f6896e46e45d76883a4eb278e54deb26f397d4e4/ACME-PS/functions/Certificate/Export-Certificate.ps1#L101

e.g.

PS /> [System.Text.Encoding]::UTF8.GetString((Invoke-ACMESignedWebRequest -Url https://acme-staging-v02.api.letsencrypt.org/acme/cert/fa42055a6bacfc97958a0a0c7cfd8c2aeade -State $acmeStateDir).Content)
-----BEGIN CERTIFICATE-----
MIIFOTCCBCGgAwIBAgITAPpCBVprrPyXlYoKDHz9jCrq3jANBgkqhkiG9w0BAQsF
ADAiMSAwHgYDVQQDDBdGYWtlIExFIEludGVybWVkaWF0ZSBYMTAeFw0yMDA1MDYw
OTE4NDhaFw0yMDA4MDQwOTE4NDhaMBsxGTAXBgNVBAMTEGEuZm9vLm1vbmthcy54
eXowggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9JMNbtvZDl70Zyyvp
W/WnDeeHfZHpDth9M7TpuDpXSWpNtnpbFa0OabdLGd7FrizzHYQX0K4SkoHbBcba
H38Rs6CJL7J2mBwwqJgqkWbYfV1DqPFBbLyd32PgxC+BkPiYM3LTz7hrY/z9mj7N
nePvjDF6gWI8CkK78e85pzoe7fva2tqatiFBg245oNDDwELhVPmawBegW/lQMEfl
z19sWTcyuGBp5zJdgflfZQUfkgEUTj4e3GcOdlqEng0QIN2okQ0FeYfwkdg9Lga2
3NuAP2znICxyXzBc5lBHShRfLv5KL62WEf4mIavVtqiQs0xKJccbTzr1De0pySyJ
8om7AgMBAAGjggJtMIICaTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYB
BQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFGECjkY2XgVF
ENaCUR3NpHHFzV89MB8GA1UdIwQYMBaAFMDMA0a5WCDMXHJw8+EuyyCm9Wg6MHcG
CCsGAQUFBwEBBGswaTAyBggrBgEFBQcwAYYmaHR0cDovL29jc3Auc3RnLWludC14
MS5sZXRzZW5jcnlwdC5vcmcwM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BFRFclzLRjo/h7
IkkfjZ8wDa7faOjVXx6n+eUQ29cIMCzr8/rNWHS9pYGGQKJiY2xmVC9h12H99Xyf
zWE9vb5zKP3MVG6neX1hSdo7PEAb9fqRhHkqVsqUvJlIRmvXvVKTwNCP3eCjRCCI
PTAvjV+4ni786iXwwFYNz8l3PmPLCyQXWGohnJ8iBm+5nk7O2ynaPVW0U2W+pt2w
SVuvdDM5zGv2f9ltNWUiYZHJ1mmO97jSY/6YfdOUH66iRtQtDkHBRdkNBsMbD+Em
2TgBldtHNSJBfB3pm9FblgOcJ0FSWcUDWJ7vO0+NTXlgrRofRT6pVywzxVo6dND0
WzYlTWeUVsO40xJqhgUQRER9YLOLxJ0O6C8i0xFxAMKOtSdodMB3RIwt7RFQ0uyt
n5Z5MqkYhlMI3J1tPRTp1nEt9fyGspBOO05gi148Qasp+3N+svqKomoQglNoAxU=
-----END CERTIFICATE-----

At the moment Export-PfxCertificate is only looking at the first (end-entity) certificate, but ideally it would pick up the full chain and include it in the PFX.

Some careful code that splits the string along the PEM encapsulation boundaries (-----BEGIN CERTIFICATE-----,-----BEGIN CERTIFICATE-----) could do the trick.

from acme-ps.

glatzert avatar glatzert commented on July 22, 2024

Hm - I was not aware of the chain being included.
I'll take a look, if I can combine them into the PFX.

from acme-ps.

asifma avatar asifma commented on July 22, 2024

@glatzert : Is there any option to include the Root CA as well? That would be awsome...
Currently have a work-around. But would be great, if it came out of the box =)

Bag Attributes
friendlyName: DST Root CA X3
subject=/O=Digital Signature Trust Co./CN=DST Root CA X3
issuer=/O=Digital Signature Trust Co./CN=DST Root CA X3
-----BEGIN CERTIFICATE-----
MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow
PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD
Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O
rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq
OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b
xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw
7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD
aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG
SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69
ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr
AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz
R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5
JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo
Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
-----END CERTIFICATE-----

from acme-ps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.