Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCD(new mode): (network::fortinet::fortigate::restapi::mode::certificates) mode certificates #5473

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

OCD-MB
Copy link

@OCD-MB OCD-MB commented Feb 28, 2025

Description:
New mode to monitor certificate expiration
this works exactly like the licenses mode network::fortinet::fortigate::restapi::mode::licenses

Mode --help:
Mode:
Check certificates.

--filter-name
        Filter certificates by name (can be a regexp).

--warning-status
        Define the conditions to match for the status to be WARNING. You
        can use the following variables: %{name}, %{status}.

--critical-status
        Define the conditions to match for the status to be CRITICAL
        (Default: '%{status} =~ /expired/i'). You can use the following
        variables: %{name}, %{status}.

--unit  Select the unit for expires threshold. May be 's' for seconds,
        'm' for minutes, 'h' for hours, 'd' for days, 'w' for weeks.
        Default is seconds.

--warning-* --critical-*
        Thresholds. Can be: 'expires'.

Execution:
./centreon_plugins.pl --plugin=network::fortinet::fortigate::restapi::plugin --mode certificates --hostname='X.X.X.X' --access-token='REST_API_ACCESS_TOKEN' --port='443' --proto='https' --warning-expires='60' --critical-expires='30' --unit='d' --curl-opt="CURLOPT_SSL_VERIFYHOST => 0" --curl-opt="CURLOPT_SSL_VERIFYPEER => 0" --filter-name="Fortinet_CA_SSL1" --debug --verbose

REST API Response format:
the raw json response follows the following format:

{
    "action": "",
    "build": 1577,
    "http_method": "GET",
    "name": "available-certificates",
    "path": "system",
    "results": [
        {
            "cert_protocol": "none",
            "comments": "This is the default CA certificate the SSL Inspection will use when generating new server certificates.",
            "exists": true,
            "ext": [
                {
                    "critical": false,
                    "data": "CA:TRUE",
                    "name": "X509v3 Basic Constraints"
                }
            ],
            "fingerprint": "F2:79:B7:F6:F2:79:B7:F6",
            "has_valid_cert_key": true,
            "is_built_in": true,
            "is_ca": true,
            "is_deep_inspection_cert": true,
            "is_default_local": false,
            "is_general_allowable_cert": true,
            "is_local_ca_cert": true,
            "is_proxy_ssl_cert": true,
            "is_ssl_client_cert": true,
            "is_ssl_server_cert": true,
            "is_wifi_cert": false,
            "issuer": {
                "C": "US",
                "CN": "FGSNXXXXXXXXXXXX",
                "emailAddress": "[email protected]",
                "L": "Sunnyvale",
                "O": "Fortinet",
                "OU": "Certificate Authority",
                "ST": "California"
            },
            "issuer_raw": "C = US, ST = California, L = Sunnyvale, O = Fortinet, OU = Certificate Authority, CN = FGSNXXXXXXXXXXXX, emailAddress = [email protected]",
            "key_size": 2048,
            "key_type": "RSA",
            "name": "Fortinet_CA_SSL1",
            "q_name": "local",
            "q_path": "vpn.certificate",
            "q_ref": 6,
            "q_static": true,
            "q_type": 168,
            "range": "global",
            "serial_number": "04:66:A8:A8:04:66:A8:A8",
            "signature_algorithm": "SHA256",
            "source": "factory",
            "status": "valid",
            "subject": {
                "C": "US",
                "CN": "FGSNXXXXXXXXXXXX",
                "emailAddress": "[email protected]",
                "L": "Sunnyvale",
                "O": "Fortinet",
                "OU": "Certificate Authority",
                "ST": "California"
            },
            "subject_raw": "C = US, ST = California, L = Sunnyvale, O = Fortinet, OU = Certificate Authority, CN = FGSNXXXXXXXXXXXX, emailAddress = [email protected]",
            "type": "local-ca",
            "valid_from": 1636382833,
            "valid_from_raw": "2021-11-08 14:47:13  GMT",
            "valid_to": 1952002033,
            "valid_to_raw": "2031-11-09 14:47:13  GMT",
            "version": 3
        },
        {
            "cert_protocol": "none",
            "comments": "This is the default CA certificate the SSL Inspection will use when generating new server certificates.",
            "exists": true,
            "ext": [
                {
                    "critical": false,
                    "data": "CA:TRUE",
                    "name": "X509v3 Basic Constraints"
                }
            ],
            "fingerprint": "F2:79:B7:F6:F2:79:B7:F6",
            "has_valid_cert_key": true,
            "is_built_in": true,
            "is_ca": true,
            "is_deep_inspection_cert": true,
            "is_default_local": false,
            "is_general_allowable_cert": true,
            "is_local_ca_cert": true,
            "is_proxy_ssl_cert": true,
            "is_ssl_client_cert": true,
            "is_ssl_server_cert": true,
            "is_wifi_cert": false,
            "issuer": {
                "C": "US",
                "CN": "FGSNXXXXXXXXXXXX",
                "emailAddress": "[email protected]",
                "L": "Sunnyvale",
                "O": "Fortinet",
                "OU": "Certificate Authority",
                "ST": "California"
            },
            "issuer_raw": "C = US, ST = California, L = Sunnyvale, O = Fortinet, OU = Certificate Authority, CN = FGSNXXXXXXXXXXXX, emailAddress = [email protected]",
            "key_size": 2048,
            "key_type": "RSA",
            "name": "Fortinet_CA_SSL",
            "q_name": "local",
            "q_path": "vpn.certificate",
            "q_ref": 6,
            "q_static": true,
            "q_type": 168,
            "range": "global",
            "serial_number": "04:66:A8:A8:04:66:A8:A8",
            "signature_algorithm": "SHA256",
            "source": "factory",
            "status": "valid",
            "subject": {
                "C": "US",
                "CN": "FGSNXXXXXXXXXXXX",
                "emailAddress": "[email protected]",
                "L": "Sunnyvale",
                "O": "Fortinet",
                "OU": "Certificate Authority",
                "ST": "California"
            },
            "subject_raw": "C = US, ST = California, L = Sunnyvale, O = Fortinet, OU = Certificate Authority, CN = FGSNXXXXXXXXXXXX, emailAddress = [email protected]",
            "type": "local-ca",
            "valid_from": 1732824780,
            "valid_from_raw": "2024-11-28 20:13:00  GMT",
            "valid_to": 1804104780,
            "valid_to_raw": "2027-03-03 20:13:00  GMT",
            "version": 3
        },
        {
            "cert_protocol": "none",
            "comments": "This is the default CA certificate the SSL Inspection will use when generating new server certificates.",
            "exists": true,
            "ext": [
                {
                    "critical": false,
                    "data": "CA:TRUE",
                    "name": "X509v3 Basic Constraints"
                }
            ],
            "fingerprint": "F2:79:B7:F6:F2:79:B7:F6",
            "has_valid_cert_key": true,
            "is_built_in": true,
            "is_ca": true,
            "is_deep_inspection_cert": true,
            "is_default_local": false,
            "is_general_allowable_cert": true,
            "is_local_ca_cert": true,
            "is_proxy_ssl_cert": true,
            "is_ssl_client_cert": true,
            "is_ssl_server_cert": true,
            "is_wifi_cert": false,
            "issuer": {
                "C": "US",
                "CN": "FGSNXXXXXXXXXXXX",
                "emailAddress": "[email protected]",
                "L": "Sunnyvale",
                "O": "Fortinet",
                "OU": "Certificate Authority",
                "ST": "California"
            },
            "issuer_raw": "C = US, ST = California, L = Sunnyvale, O = Fortinet, OU = Certificate Authority, CN = FGSNXXXXXXXXXXXX, emailAddress = [email protected]",
            "key_size": 2048,
            "key_type": "RSA",
            "name": "Fortinet_CA_SSL2",
            "q_name": "local",
            "q_path": "vpn.certificate",
            "q_ref": 6,
            "q_static": true,
            "q_type": 168,
            "range": "global",
            "serial_number": "04:66:A8:A8:04:66:A8:A8",
            "signature_algorithm": "SHA256",
            "source": "factory",
            "status": "valid",
            "subject": {
                "C": "US",
                "CN": "FGSNXXXXXXXXXXXX",
                "emailAddress": "[email protected]",
                "L": "Sunnyvale",
                "O": "Fortinet",
                "OU": "Certificate Authority",
                "ST": "California"
            },
            "subject_raw": "C = US, ST = California, L = Sunnyvale, O = Fortinet, OU = Certificate Authority, CN = FGSNXXXXXXXXXXXX, emailAddress = [email protected]",
            "type": "local-ca",
            "valid_from": 1732824775,
            "valid_from_raw": "2024-11-28 20:12:55  GMT",
            "valid_to": 1804104775,
            "valid_to_raw": "2027-03-03 20:12:55  GMT",
            "version": 3
        }
    ],
    "serial": "FGSNXXXXXXXXXXXX",
    "status": "success",
    "vdom": "root",
    "version": "v7.2.0"
}

@OCD-MB OCD-MB requested a review from a team as a code owner February 28, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants