How to create fullchain.pem from cert.pem?

Hi, I’m using Certify The Web application for wildcard-certificate renewal on dedicated IIS server. It works great.

Now I’m trying to load this certificate to the separate shared hosting, but control panel asks to include a full certificate chain to that wildcard-certificate.

I downloaded cert.pfx from IIS Manager server certificates and made cert.pem using openssl tool:

openssl pkcs12 -chain -in cert.pfx -out cert.pem -nodes

I don’t see any options in Certify app for this, so now I guess I have to manually add some certificates. But I don’t understand which certificates should I manually add (root, cross-signed or what?) and at what part of the pem certificate?

Thanks in advance

1 Like

cat cert.pem ca.pem > fullchain.pem

Ok, you are on windows. Make a copy of cert.pem, name it fullchain. Open this copy, and paste ca.pem at the end. Done.

How to get ca.pem? Is it root certificate from https://letsencrypt.org/certificates/?

You should have it already, even if it’s called differently.

Anyway, it’s the intermediate (and maybe then the root).

1 Like

@Ice2burn open your certificate and tell me how many lines like

===== BEGIN SOMETHING =====

there are

It has one “-----BEGIN PRIVATE KEY-----” line and one “-----BEGIN CERTIFICATE-----” line.

For deployed ssl-certificate this command:

openssl s_client -showcerts -verify 5 -connect wss.fansy-service.ru:443

returns two “-----BEGIN CERTIFICATE-----” lines

this doesn’t sound good, strange format

this sounds like a fullchain

this doesn’t sound good, strange format

This is what I get by executing command in the first message. “-nodes” means not to encrypt key.

Should learn how to retrieve ca.pem in the first place.

read this: https://www.openssl.org/docs/man1.0.2/man1/pkcs12.html

I think you should change your openssl command:

openssl pkcs12 -chain -in cert.pfx -out fullchain.pem -nokeys

It returns only single “-----BEGIN CERTIFICATE-----”.

Saw an error in console on "s_client " :

depth=1 C = US, O = Let’s Encrypt, CN = Let’s Encrypt Authority X3
verify error:num=20:unable to get local issuer certificate

Maybe I should install Let’s Encypt certificates on server manually.

Install the root. The intermediate should already be there.

Unfortunately, nothing changed

I think you should complain to them shared hosting people. Or give the same certificate in both fields.

Anyway, it’s the intermediate (and maybe then the root).

I manually added intermediate сertificate to the end of the cert.pem and control panel accepted it.

Too bad I can’t figure it out how to properly made it with a console. Thanks for the help.

Try with -cacerts -nokeys for the chain. In another pass -nocerts to get the key.

openssl pkcs12 -chain -in cert.pfx -out chain.pem -cacerts -nokeys

As result, the file is empty.
Root and intermediate certs were installed using Certificate Import Wizard.

That doesn’t seem right to me. The PKCS12 bundle should contain two certificates.

If you’re only seeing one certificate with that command, it means Certify the Web didn’t include an intermediate in the bundle. At that point, there’s nothing you can really do except fetch it manually.

Edit: I noticed that you downloaded the PFX from IIS. Can you try fetch it from Certify the Web instead?

$ openssl pkcs12 -in bundle.pfx -nokeys
Enter Import Password:
Bag Attributes
    localKeyID: 6B C9 2A A8 49 3F 7C D3 E5 A8 E9 ED 30 DB 87 16 2E 28 FF 52
subject=CN = monkas.xyz

issuer=CN = Fake LE Intermediate X1

-----BEGIN CERTIFICATE-----
MIIFPDCCBCSgAwIBAgITAPpfS5Nv9KPM1j/0jv6IgaWDETANBgkqhkiG9w0BAQsF
ADAiMSAwHgYDVQQDDBdGYWtlIExFIEludGVybWVkaWF0ZSBYMTAeFw0xOTAzMDQy
MTAyNDZaFw0xOTA2MDIyMTAyNDZaMBUxEzARBgNVBAMTCm1vbmthcy54eXowggEi
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6qUuagETgFwgH0MthCtvl1WPe
ne2EBsbTXAc2Ex51uWxZfER1Ov3QnCHJP8VlT9M/4vUgQfV8KWwd42d/nUv2/mv+
hiA53Lrkv73FH+JHGc7i0mSiwH0LEIhVaegZ/BPHG4Mx2EmOmNb5QB7yUyPLiz/j
QhtK9sczYkeWxpDahk7XQxyWvvnbgqtxSIWHDI7rgWL8ceF8M1zes/10lwmOGrlM
vGgOtH1gpzIlUkel0MEJ1zrZvzf2hdKFYQz2NBHJ7x5vmz1tfHsPGhVkWs/lji1i
jN8cU7ceML4d1Xg0YJN/QUsZjcwTJnY8ZR2iKrQMT2RxvUmyJ7WqAaG01943AgMB
AAGjggJ2MIICcjAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEG
CCsGAQ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GDAWgBTBJnSkikSg5vogKNhcI5pFiBh54DANBgkq
hkiG9w0BAQsFAAOCAgEABYSu4Il+fI0MYU42OTmEj+1HqQ5DvyAeyCA6sGuZdwjF
UGeVOv3NnLyfofuUOjEbY5irFCDtnv+0ckukUZN9lz4Q2YjWGUpW4TTu3ieTsaC9
AFvCSgNHJyWSVtWvB5XDxsqawl1KzHzzwr132bF2rtGtazSqVqK9E07sGHMCf+zp
DQVDVVGtqZPHwX3KqUtefE621b8RI6VCl4oD30Olf8pjuzG4JKBFRFclzLRjo/h7
IkkfjZ8wDa7faOjVXx6n+eUQ29cIMCzr8/rNWHS9pYGGQKJiY2xmVC9h12H99Xyf
zWE9vb5zKP3MVG6neX1hSdo7PEAb9fqRhHkqVsqUvJlIRmvXvVKTwNCP3eCjRCCI
PTAvjV+4ni786iXwwFYNz8l3PmPLCyQXWGohnJ8iBm+5nk7O2ynaPVW0U2W+pt2w
SVuvdDM5zGv2f9ltNWUiYZHJ1mmO97jSY/6YfdOUH66iRtQtDkHBRdkNBsMbD+Em
2TgBldtHNSJBfB3pm9FblgOcJ0FSWcUDWJ7vO0+NTXlgrRofRT6pVywzxVo6dND0
WzYlTWeUVsO40xJqhgUQRER9YLOLxJ0O6C8i0xFxAMKOtSdodMB3RIwt7RFQ0uyt
n5Z5MqkYhlMI3J1tPRTp1nEt9fyGspBOO05gi148Qasp+3N+svqKomoQglNoAxU=
-----END CERTIFICATE-----

You can also look at some of the bundled export scripts that come with Certify the Web, which basically do the same thing:

@webprofusion the PFX should contain the intermediate, right? Even if downloaded from IIS Manager?

1 Like

Yes, the PFX from Certify The Web is a bundle containing the end-entity cert, the intermediates and the private key used for the certificate signing request (in this case that’s different for every cert). You can see the path to the current certificates PFX file under Show Advanced Options> Other Options and just copy that file and work with it directly.

So there is no need to export the certificate (it’s already on disk) and the normal method would be to script the conversion of the pfx to the component parts you need using Shows Advanced Options > Scripting options and a local copy of OpenSSL e.g.: https://docs.certifytheweb.com/docs/script-hooks#example-export-certificate-using-openssl-to-pemcrtkey-etc-for-apache-and-other-services

The upcoming V5 of Certify The Web has a new Deployment Tasks UI feature which allows additional deployment tasks like exports to various formats and presets for popular servers like Apache and nginx as well as SSH/SFTP options for automated deployment to other services as part of the renewal process (optionally, they can also be deferred and run from the command line manually or as a scheduled task).

As an aside, what made you come to this forum for help instead of going to https://community.certifytheweb.com/ ? Just wondering if I need to make something more prominent on the website (depends how you found the app in the first place).

4 Likes

Success, it’s located in “C:\ProgramData\Certify\certes\assets\pfx” with empty password and pfx contains intermediate cert as well. Didn’t think about it. Thanks

1 Like

Thanks, didn’t pay attention to the advanced options. I thought I can retrieve the cert only with Server Manager where I see it directly after every renewal.

Yeah, it’s an advanced level of administration. I’m not there yet :sweat_smile:

I was thinking it’s something trivial, cause problem related to my lack of knowledge about certificates and not to CTW. And 9peppe answered in his second message about intermediate cert and it helped.

Anyway, thank you all for the help, didn’t expect so much attention to the problem :+1:

2 Likes