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

Looking for a Fortinet Consultant

Having trouble with FortiGate REST API calls for automated policy updates. We're using Python scripts to bulk modify firewall rules but getting SSL certificate validation errors when connecting to our FortiGate cluster.

Individual policy queries work through the web interface, but programmatic access via API keeps failing on certificate handshake. Need someone experienced with FortiOS API authentication and certificate management.

Requires 2-3 hours remote session to resolve the SSL connectivity issues. Timeline is urgent - need functional by Wednesday for security policy rollout.

3 REPLIES 3
funkylicious
SuperUser
SuperUser

hi,

not a Fortinet expert here, especially on the API/automation side.

are you using a API token ( authorization bearer ) for connecting to the firewall or with a username and password ?

can you share more info about the error or the request that you are using ?

"jack of all trades, master of none"
"jack of all trades, master of none"
distillednetwork
Contributor III

Are you using a publicly signed certificate on the management interface, and if so, using that FQDN (not IP) to connect to the firewall?  If it's not a publicly signed cert, you will have to download it and then upload it to your server to explicitly trust it.  I'm not sure the exact libraries you are looking at, but this may help:

 

https://www.geeksforgeeks.org/python/ssl-certificate-verification-python-requests/

 

Markus_M
Staff & Editor
Staff & Editor

The API is basically HTTPS access. The API key is just doing authentication AFTER the HTTPS or rather TLS exchange. The policy update or whatever will be done AFTER that.

So your python script will be the HTTPS/TLS client to the FortiGate as TLS server. No idea what your client is, but I assume it offloads that task to the OS and as such - do you have certificate warnings with a browser that uses the FortiGate certificate store when access the FortiGate on the exact same address as your python script?

- Markus
Announcements
Check out our Community Chatter Blog! Click here to get involved
Labels
Top Kudoed Authors