Fortinet Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
Contributor II

Let's Encrypt and FortiGate

Do u know if it's possible to use a Let's Encrypt-generated certificate into the FortiGate for the VPN Portal?

5 Solutions

No, I don't think that you can use LE certificates. You need their app on the device to use it. But you can use startssl

View solution in original post

Esteemed Contributor III

Mhe has it right.


Natively the answer is NO, but you have ways around this. Use a linux bistro build a csr/priv-key sign the csr and then export , re-import it in fortigate.


Yes any x509 compatible certificate will work in  a fortigate but the native means of "let's encrypt" make it not a 1 2 3  easy-do  method.




View solution in original post


The problem with the manual import is that you will be running the manual process probably 5 times a year as letsencrypt issuance is 90days.

"Our certificates are valid for 90 days. You can read about why here."



View solution in original post


So here's what I did using a raspberry pi, but can be easily used on other platforms...



  • Install letsencrypt ( on a box with tcp/80, tcp/443 open. (Raspberry Pi - used CertBot)
  • Temporarily point a DNS A or CNAME record of your (Raspberry Pi Box) SSL VPN at the box you're going to run letsencrypt on.
  • Once it pulls dependencies - Run letsencrypt using example below.
  • [ol]
  •  ./certbot-auto certonly --standalone -d -d [[/ol]
  • Change DNS records if required by pointing your DNS A record back at your SSL VPN IP
  • Grab your pems from /etc/letsencrypt/live/ (cert.pem & privkey.pem) [/ol]


  • System -> Config -> Certificates -> Import -> Local Certificate. Set type to Certificate. For certificate choose cert.pem and for key choose privkey.pem

  • VPN -> SSL -> Settings. Change Server Certificate.

  • Repeat process every 90 days
  • Setup CronJob to renew it.[/ol]
  • View solution in original post


    Just updating this thread to mention that ACME/LetsEncrypt functionality is now built into FortiOS 7.0. New Features | FortiGate / FortiOS 7.0.0 | Fortinet Documentation Library Russ NSE7

    View solution in original post

    46 REPLIES 46

    For anyone finding this I was able to load up a CentOS 7 and used DNS verification. 


    wget [link][/link] chmod a+x certbot-auto

    ./certbot-auto -d  --manual --preferred-challenges dns certonly


    It asks some questions, the end is below. 


    NOTE: The IP of this machine will be publicly logged as having requested this certificate. If you're running certbot in manual mode on a machine that is not your server, please ensure you're okay with that.

    Are you OK with your IP being logged? ------------------------------------------------------------------------------- (Y)es/(N)o: Y

    ------------------------------------------------------------------------------- Please deploy a DNS TXT record under the name with the following value:


    Before continuing, verify the record is deployed. ------------------------------------------------------------------------------- Press Enter to Continue Waiting for verification... Cleaning up challenges

    Obviously, before I pressed enter to continue I hopped over to my DNS provider (in my case godaddy) and created the TXT record. I also switched to a different session on the box that I'm running certbot on and made sure I could resolve the verification text, since DNS may take a bit to propagate

    dig -t txt | grep "hFBS2IaC5exxxxxxxxxxxxLptVhZRSBi2_DNxrJmiAZDor8"

    Then I switched back to my regular console and pressed enter, it verified and spat out my certs to /etc/letsencrypt/live/hostname/stuff


    SCP'd those certs down. 


    Popped up the fortigate admin pane, System -> Certificates (I had to System -> Feature Visibility -> Enable Certificates and save for this to show up) -> I did Import -> Local Certificate -> Certificate. I used the Fullchain.pem (to be safe in case the fortigate didn't trust the LE CA or whatev. and the privkey) 



    Then I just had to go to VPN -> SSL VPN Settings -> Change the certificate 


    Et voila! 


    LE has some stuff around for setting up renewals too. My next venture will be seeing if I can figure out how to install the cert at the SSH of the fortigate or something. On other linux boxen I've done it with SCPing the cert to the host and then installing it. Thinking maybe I can do similar with the fortigate. 


    Anywho, good luck fellow interneters. and remember the wisdom of XKCD, 

    All long help threads should have a sticky globally-editable post at the top saying 'DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far ...'




    The problem is that they need you to use their tool, certbot and it wont run on FortiGate.

    There's also a manual mode, but AFAIK you cant upload custom files neither.


    What would i do? I'd set a Virtual IP on 80/443 pointing to a server under your contro, where you can run certbot. Once the VIP is active, i'd run certbot, get the certificate and then import them on FortiGate.


    The problem? You would have to do this every three months.


    Esteemed Contributor III

    I agreed with agent1994 and that exactly how we do it. We use a VIP that we stroke for the  DNS check and then  reuse that  ip.addr for the  SSL-TERMINATION point on a loopback,


    It's a b#$#$@ that we have to  do this, but we  go thru the process every 3months and just take the SSLVPN for 15mins to re-import a certificate, but it works out very good for us.







    So I found and tested this method.


    still working on it, but it looks like I can SSH to the Fortigate and apply the SSL cert this way 


    just gotta work out the part about running the commands in the SSH session and passing it the certificate


    Esteemed Contributor III

    if your this far, than your golden &  just need to  build a script and add the PEM format cat it into  fgt


    e.g ( my filename == LETENC)


    config vpn certificate local  edit fgtLetsEncrypt

    set private-key "-----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC0580JLqtyx8NY J12uvTZrYNJxyio3GmWJKvL+SPwY8c056WofC8OVOYOGCIBieb9cV87mnTQrwH/r Vk4kXJQtRru7fsW6pX0fFrAXuBluJ8F2wrN3cuxajaHlj0ZJ4eDKeOc8YiUbE9ow Wj+TpetXNKmNddCAqVJOnHrkHN5Fy4x9hUq3XroSIHHAaerwYYyZHpXkaAPnuhUZ 7Kc59dty/8dswGpy8daosPlldXlfrSJe+KkMuLY5IlkqRwyA/LQRvOY0wereI6GQ bF1Hi2GcZfnr0auzkTrF//HCcrx3dYHAZwxXkuwDQUAYehry2NGI4q0bMxkS/1hL lpkW65uZAgMBAAECggEANm50k+m17oBKt5CIsJX/9MkaKODCWPgZSu9gU8CUEdFX hbBEnPjGLXUzrLWMI5UsTdWhzGPKmct+8clzE5/DeegJfn3DcshuYFdMPqbHCAzw OhKVO0CZ+xkYeGDmrj5Hi8RbFyEUtxP/F4NgE8XdjMyso4KqbLwFpt+QXmiNPIRj ixsprTurtnLQ1sfM5+K7Q8tqnuVXPt8oawssONsL3YeXcMDn7YOIEFvJurQAEl6w 05CK07fA2ED2KixcTNtMKdBbIiqgQ78Y2mwzdEhZNFhW7uOzNXiylvCDF0zyZoN8 s/XB6a6s/hGp8QOn6FcNX01bdzJKuyEcW0zh5wPOcQKBgQDlPpggSq5paLlABr0f 9DEe7D3QaYX0fZYdHouOTo9AW+C/ht7grkus3xFPfCU6US2QSxbM0D9L3NJ4OBe6 3XwAd0ezkgZZBA3cEHnLr/30cTEgnLclvZJBSOYsz5c40u3TJVDUrNMRnqP4GgPf KfhZST8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nNidGVzdC5wdWJsaWNwYXJ0bmVyc2hpcHMuY29t MB8GA1UdIwQYMBaAFIKicHTdvFM/z3vU981/p2DGCky/MB0GA1UdDgQWBBR5IxFF bMXRqzauIqKQ1iMnuwCd7zAJBgNVHRMEAjAAMA0GCSqGSIb3DQEBCwUAA4IBAQDO mOGvvwiNhrGuF0NTIhrBlcmaWu7Df4yHCVnFWASCkW/ueRinLrXtp2uZxRD7izJZ ffp5qzdjiROtnkm1WNpI4jhnr8w1pHTjcMgpbZm2YnCk/b1u7CBGDtXykAcdNrj1 yZNZx3QZaNZnaWNnZ40YM/+5xjK1OJtNKa8y6Mt+YuVy3BeLqK1vfw4cue0j0Nbh FbcQaTRWKtIyTu4s4fdebtsUEqwSZYxrL1l5VEuBn3l+yIBvBsWEOTEa1YjmL0Pd ReEDsIR6ZuXIVi1eX7YAIrYEp2JTvzWZYfBqOc/YsUB7J1xZQGRNRnHqK2furyko VLFU4qHPO+O6WMMFUn8z -----END CERTIFICATE-----" end


    and finally you run it;


    cat LETENC | kfelix.socpuppets@


    This will copy the content into the local CERTstore priv-key and x509-cert







    Esteemed Contributor III

    TIP :  Also make sure you  use " " for the priv-key 1st and then then the "cert". You can hack up the LETENC  seedfile with sed/awk whenever your  certificate and key changes and repeat every 3 months or so.


    I use this same above approach when mass blasting free also btw.








    New Contributor

    Yes, it is. It is even possible with a self-signed certificate.


    1- Go under: System --> Certificates then Import your certificate & CA.

    2- Go under: VPN --> SSL --> Settings --> Connection Settings --> Server Certificate then choose the Let's Encrypt certificate.



    anyone have any luck creating a script for automated cert renewal?


    I solved it by setting up a reverse proxy using Traefik and Letsencrypt to give me access to mgmt and SSL VPN through the proxy, that way I get automatically updated certificates for both services by bouncing it on the inside, can't say it's affecting performance either.


    I'm working on a python script that will kick off after a certbot renewal and use the fortios API to upload the certificates and migrate the old certificate with the new one. I'll let you know how it goes. Also since now you can use DNS validation and get wild card certs you no longer have to use a public facing web server to do the certificate process, you just need internet access and API access to your DNS servers.