FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
Sachin_Alex_Cherian_
Article Id 427172
Description

This article offers a different approach that uses OpenSSL to revalidate the signed certificate and the original certificate signing request, assisting in verifying the accuracy of the errors displayed by FortiGate when importing a CA-signed certificate for a Certificate Signing Request generated on FortiGate.

Scope

FortiGate. 

Pre-Requisite: Binaries for OpenSSL should be installed/available on the local PC/machine.

Solution

Consider a new Certificate Signing Request generated from FortiGate as below:

 

FGT-CSR-Snipp.jpg

 

Once the Certificate Signing Request is generated it will appear under the Certificates tab with a ‘Pending’ status.

 

FGT-CSR-status.jpg

 

This ‘FG-VM1-GUI.csr’ file would then be downloaded and signed by an external Certificate Authority.

After the Certificate Authority (whether it be internal or external) signs the request, the certificate will be provided which then needs to be imported back to FortiGate.

In this case, the Certificate Authority used was an internal FortiAuthenticator which was used to sign the request and the signed certificate exported from the FortiAuthenticator is named ‘FG_VM1_GUI.crt’.

 

To validate the presented certificate matches the original Certificate Signing request, OpenSSL can be used.

The command below runs the modulus operation on the certificate signing request:

 

openssl req -noout -modulus -in <certificate_signing_request>

 

For example, modulus generated for FG-VM1-GUI.csr is shown below:


C:\Users\admin\Downloads\OpenSSL>openssl req -noout -modulus -in FG-VM1-GUI.csr


Modulus=A58E4042BBA3F7340D2EA12801532B717281B47BD1C6E969836CF03F14ED09537E23E8B3
F6A0EA8DCF44A1A9C486E024C2C9F8A2EF4595ED2CB3A03BC8FB2E1C6C3287F95BD4C84A062A21F2
00EF79ECA86FEC7E1AAA95DEABAD05223940BFBDFBCDD9AB5C88605DFECF0AD93A1A9B4E4BDEF895
98B8E3BBBED1273ADD17196BE5CAC8370103E520D73A160D6219DAB8FDD4BA67B20873C1AE4EC8BC
F0BC0F240FC00A671E83C0026C362E3AE39FA0DBA3C3F257969A12CAADB1E3C306926A57BA9FC294
51485B12DACACC5667445FC9345284F4F7A8692CFFC822448E3757021D4431B8D871EA36EA043CDC
304984D97FC428155470979840A9F942CB5F1A9F8D1338CF7CE82BDD43A44055BC6224C58CAE4A29
C5C291F71750A1751ACB5412984EC7BB7B51A46C3CC48EDBEDE9D40307BFA84890D45E95F8546E60
F69312E3FA4DDACE4BC7C89143DAE02C00633E735C16BC5A43E7354F0C4370D23DD04E3585BCB33D
09550AAB45AE8B828D479BC50A9FE9F52F5AD3FA58A7D12ABB0AB23C3747153DB4D132813E2D24BE
B2CAF8B5CD4547090616608154E15874AA33BCED151681BE81304BC683EC2C76DB9E901738D99F0A
EA43D0BBCCBC9A39667128F740B6A9BAD4286323D3B760F623178B1BA6A1A2CFBF480C1841ADCE87
2BDBE027EE998405F9FE2935977EA4BB591670F6AACC126FC5DAF6A6FEF78025D4A2027D

 

The command below runs the modulus operation on the signed certificate:


openssl x509 -noout -modulus -in <certificate>


For example, modulus generated for FG_VM1_GUI.crt is shown below:


C:\Users\admin\Downloads\OpenSSL>openssl x509 -noout -modulus -in FG_VM1_GUI.crt


Modulus=A58E4042BBA3F7340D2EA12801532B717281B47BD1C6E969836CF03F14ED09537E23E8B3
F6A0EA8DCF44A1A9C486E024C2C9F8A2EF4595ED2CB3A03BC8FB2E1C6C3287F95BD4C84A062A21F2
00EF79ECA86FEC7E1AAA95DEABAD05223940BFBDFBCDD9AB5C88605DFECF0AD93A1A9B4E4BDEF895
98B8E3BBBED1273ADD17196BE5CAC8370103E520D73A160D6219DAB8FDD4BA67B20873C1AE4EC8BC
F0BC0F240FC00A671E83C0026C362E3AE39FA0DBA3C3F257969A12CAADB1E3C306926A57BA9FC294
51485B12DACACC5667445FC9345284F4F7A8692CFFC822448E3757021D4431B8D871EA36EA043CDC
304984D97FC428155470979840A9F942CB5F1A9F8D1338CF7CE82BDD43A44055BC6224C58CAE4A29
C5C291F71750A1751ACB5412984EC7BB7B51A46C3CC48EDBEDE9D40307BFA84890D45E95F8546E60
F69312E3FA4DDACE4BC7C89143DAE02C00633E735C16BC5A43E7354F0C4370D23DD04E3585BCB33D
09550AAB45AE8B828D479BC50A9FE9F52F5AD3FA58A7D12ABB0AB23C3747153DB4D132813E2D24BE
B2CAF8B5CD4547090616608154E15874AA33BCED151681BE81304BC683EC2C76DB9E901738D99F0A
EA43D0BBCCBC9A39667128F740B6A9BAD4286323D3B760F623178B1BA6A1A2CFBF480C1841ADCE87
2BDBE027EE998405F9FE2935977EA4BB591670F6AACC126FC5DAF6A6FEF78025D4A2027D

 

If the modulus is compared, the output generated matches the modulus generated against the Certificate Signing Request and the signed Certificate. Going back to FortiGate the import was successful and the status changes to ‘Valid’.

 

FGT-succes-import.jpg

 

If the full modulus output turns out to be large, the md5 hash for the modulus can be obtained for easier comparison.

The command to get the md5 hash for the certificate signing request is:

 

openssl req -noout -modulus -in <CSR> | openssl md5

 

For example:

 

C:\Users\admin\Downloads\OpenSSL>req -noout -modulus -in FG-VM1-GUI.csr | openssl md5

MD5(stdin)= 2ac05eb519bb9dc1611c53eb8a580601

 

The command to get the md5 hash for the signed certificate is:

 

openssl x509 -noout -modulus -in <certificate> | openssl md5

 

For example:

 

C:\Users\admin\Downloads\OpenSSL>openssl x509 -noout -modulus -in FG_VM1_GUI.crt | openssl md5

MD5(stdin)= 2ac05eb519bb9dc1611c53eb8a580601

 

The hashes generated for the modulus of the certificate signing request and the signed certificate is the same.

 

Below is a situation where the Certificate Signing Request and the imported signed Certificate are not matched as displayed by the FortiGate and the import fails:

 

key_pair_mismatch error.jpg

 

Further validation using OpenSSL shows the md5 hash generated for the modulus does not match.

 

C:\Users\admin\Downloads\OpenSSL>openssl req -noout -modulus -in fgvm2-GUI.csr | openssl md5

MD5(stdin)= 7afc15dd6126715f4bd86b16741256e7

 

C:\Users\admin\Downloads\OpenSSL>openssl x509 -noout -modulus -in fgvm2_GUI.crt | openssl md5

MD5(stdin)= 0f0bc9b1754dce742aafb489aafa49ba