When trying to call the Checkpoint management API i received a generic 503 error like this:
[Expert@mgmt_server:0]# mgmt_cli login user "myuser" password mypassword" -f json
{
"code" : "generic_error",
"message" : "Error 503. The Management API service is not available. Please check that the Management API server is up and running."
}
The API status only confirmed that the API was not running but no more clues:
[Expert@mgmt_server:0]# api status
API Settings:
---------------------
Accessibility: Require all granted
Automatic Start: Enabled
Processes:
Name State PID More Information
-------------------------------------------------
API Stopped
CPM Started 29253 Check Point Security Management Server is running and ready
FWM Started 27142
APACHE Started 8772
Port Details:
-------------------
JETTY Internal Port:
APACHE Gaia Port: 443
Profile:
------------
Machine profile: 24800-35800 with SME
CPM heap size: 2048m
API heap size:
--------------------------------------------
Overall API Status: The API Server Is Not Running!
--------------------------------------------
Notes:
------------
To collect troubleshooting data, please run 'api status -s <comment>'
Checking the "api.elg" log file took me to the correct path:
[Expert@mgmt_server:0]# tail -20 /opt/CPsuite-R80.40/fw1/log/api.elg | grep -i error
2024-03-27 08:58:09,072 WARN org.eclipse.jetty.xml.XmlParser.fatalError:404 [main] - FATAL@null line:-1 col:-1 : org.xml.sax.SAXParseException: Premature end of file.
Seems that $FWDIR/api/conf/jetty.xml file is empty:
[Expert@mgmt_server:0]# cat $FWDIR/api/conf/jetty.xml
[Expert@mgmt_server:0]#
With a bit more research i found this official article:https://support.checkpoint.com/results/sk/sk144332
I had to recover the contents of the file by installing another management server in a different machine. (check this post https://somoit.net/checkpoint/checkpoint-recover-sms-disaster/ the steps "install checkpoint 1" and "install checkpoint 2"). After installing and copying the file into the production server, i started the api server succesfully:
[Expert@mgmt_server:0]# api start
2024-Mar-27 09:04:01 - Starting API...
. . . . . . . .
2024-Mar-27 09:04:48 - API started successfully.
And again i was able to use it and make calls:
[Expert@mgmt_server:0]# mgmt_cli login user "myuser" password "mypassword" -f json
{
"uid" : "*******************************",
"sid" : "********************************************",
"url" : "https://127.0.0.1:443/web_api",
"session-timeout" : 600,
"api-server-version" : "*.*.*"
}