certspotter-script(8)
π certspotter-script(8) π
okay bestie, welcome to the System Manager's Manual page for certspotter-script π
β¨ NAME β¨
certspotter-script β Certificate Transparency Log Monitor (hook script) π
πΈ DESCRIPTION πΈ
so certspotter-script is literally any program that gets run by certspotter(8) when it needs to yell at you about an event, like spotting a certificate for a domain on your watch list. not me being the notification system π
scripts live in the $CERTSPOTTER_CONFIG_DIR/hooks.d directory (~/.certspotter/hooks.d by default), or you can just point at one on the command line with the -script argument. easy peasy π¦
π§ ENVIRONMENT π§
π Event information
these environment variables get set for all types of events, no matter what:
EVENTβ one of these values, telling you what kind of event it is:discovered_certβ certspotter has discovered a certificate for a domain on your watch list πmalformed_certβ certspotter can't determine if a certificate matches your watch list because the certificate or the log entry is malformed πerrorβ a problem is preventing certspotter from monitoring all logs π
extra event types might get defined in the future, so your script should be able to handle unknown values. foresight is main character energy β¨
SUMMARYβ a short human-readable string describing the event. it's the same string used in the subject line of emails sent by certspotter π§
π Discovered certificate information
these environment variables get set for discovered_cert events:
WATCH_ITEMβ the item from your watch list which matches this certificate. (if more than one item matches, the first one is used π)LOG_URIβ the URI of the log containing the certificate.ENTRY_INDEXβ the index of the log entry containing the certificate.TBS_SHA256β the hex-encoded SHA-256 digest of the TBSCertificate, as defined in RFC 6962 Section 3.2. certificates and their corresponding precertificates have the sameTBS_SHA256value π«ΆCERT_SHA256β the hex-encoded SHA-256 digest (sometimes called fingerprint) of the certificate. the digest is computed over the ASN.1 DER encoding.PUBKEY_SHA256β the hex-encoded SHA-256 digest of the certificate's Subject Public Key Info.CERT_FILENAMEβ path to a file containing the PEM-encoded certificate chain. not set if-no_savewas used πJSON_FILENAMEβ path to a JSON file containing additional information about the certificate. see below for the format of the JSON file. not set if-no_savewas used.TEXT_FILENAMEβ path to a text file containing information about the certificate. this file contains the same text that certspotter uses in emails. you should not attempt to parse this file because its format may change in the future π€ not set if-no_savewas used.NOT_BEFORE,NOT_BEFORE_UNIXTIME,NOT_BEFORE_RFC3339β the not before time of the certificate, in a human-readable format, seconds since the UNIX epoch, and RFC3339, respectively. these variables may be unset if there was a parse error, in which caseVALIDITY_PARSE_ERRORis set.NOT_AFTER,NOT_AFTER_UNIXTIME,NOT_AFTER_RFC3339β the not after (expiration) time of the certificate, in a human-readable format, seconds since the UNIX epoch, and RFC3339, respectively. these variables may be unset if there was a parse error, in which caseVALIDITY_PARSE_ERRORis set.VALIDITY_PARSE_ERRORβ error parsing not before and not after, if any. if this variable is set, then theNOT_BEFOREandNOT_AFTERfamily of variables are unset.SUBJECT_DNβ the distinguished name of the certificate's subject. this variable may be unset if there was a parse error, in which caseSUBJECT_PARSE_ERRORis set.SUBJECT_PARSE_ERRORβ error parsing the subject, if any. if this variable is set, thenSUBJECT_DNis unset.ISSUER_DNβ the distinguished name of the certificate's issuer. this variable may be unset if there was a parse error, in which caseISSUER_PARSE_ERRORis set.ISSUER_PARSE_ERRORβ error parsing the issuer, if any. if this variable is set, thenISSUER_DNis unset.SERIALβ the hex-encoded serial number of the certificate. prefixed with a minus (-) sign if negative. this variable may be unset if there was a parse error, in which caseSERIAL_PARSE_ERRORis set.SERIAL_PARSE_ERRORβ error parsing the serial number, if any. if this variable is set, thenSERIALis unset.
π Malformed certificate information
these environment variables get set for malformed_cert events:
LOG_URIβ the URI of the log containing the malformed certificate.ENTRY_INDEXβ the index of the log entry containing the malformed certificate.LEAF_HASHβ the base64-encoded Merkle hash of the leaf containing the malformed certificate.PARSE_ERRORβ a human-readable string describing why the certificate is malformed.ENTRY_FILENAMEβ path to a file containing the JSON log entry. the file contains a JSON object with two fields,leaf_inputandextra_data, as described in RFC 6962 Section 4.6.TEXT_FILENAMEβ path to a text file containing a description of the malformed certificate. this file contains the same text that certspotter uses in emails.
π Error information
these environment variables get set for error events:
TEXT_FILENAMEβ path to a text file containing a description of the error. this file contains the same text that certspotter uses in emails.
π JSON FILE FORMAT π
unless -no_save is used, certspotter saves a JSON file for every discovered certificate under $CERTSPOTTER_STATE_DIR, and puts the path to the file in $JSON_FILENAME. your script can read the JSON file, like with the jq(1) command, to get additional information about the certificate which isn't appropriate for environment variables β¨
the JSON file contains an object with these fields:
tbs_sha256β a string containing the hex-encoded SHA-256 digest of the TBSCertificate, as defined in RFC 6962 Section 3.2. certificates and their corresponding precertificates have the sametbs_sha256value.pubkey_sha256β a string containing the hex-encoded SHA-256 digest of the certificate's Subject Public Key Info.dns_namesβ an array of strings containing the DNS names for which the certificate is valid, taken from both the DNS subject alternative names (SANs) and the subject common name (CN). Internationalized domain names are encoded in Punycode.ip_addressesβ an array of strings containing the IP addresses for which the certificate is valid, taken from both the IP subject alternative names (SANs) and the subject common name (CN).not_beforeβ a string containing the not before time of the certificate in RFC3339 format.Nullif there was an error parsing the certificate's validity.not_afterβ a string containing the not after (expiration) time of the certificate in RFC3339 format.Nullif there was an error parsing the certificate's validity.
additional fields will be added in the future based on user feedback. please open an issue at https://github.com/SSLMate/certspotter if you have a use case for another field π (they're literally asking for your ideas, go off)
π₯ EXAMPLES π₯
example environment variables for a discovered_cert event:
CERT_FILENAME=/home/andrew/.certspotter/certs/3c/3cdc83b3932c194fcdf17aa2bf1abc34e8438b293c3d5c70693e175b38ff128a.pem
CERT_SHA256=3cdc83b3932c194fcdf17aa2bf1abc34e8438b293c3d5c70693e175b38ff128a
ENTRY_INDEX=6464843
EVENT=discovered_cert
ISSUER_DN=C=GB, ST=Greater Manchester, L=Salford, O=Sectigo Limited, CN=Sectigo RSA Domain Validation Secure Server CA
JSON_FILENAME=/usr2/andrew/.certspotter/certs/3c/3cdc83b3932c194fcdf17aa2bf1abc34e8438b293c3d5c70693e175b38ff128a.v1.json
LOG_URI=https://ct.cloudflare.com/logs/nimbus2024/
NOT_AFTER='2024-01-26 03:47:26 +0000 UTC'
NOT_AFTER_RFC3339=2024-01-26T03:47:26Z
NOT_AFTER_UNIXTIME=1706240846
NOT_BEFORE='2023-01-31 03:47:26 +0000 UTC'
NOT_BEFORE_RFC3339=2023-01-31T03:47:26Z
NOT_BEFORE_UNIXTIME=1675136846
PUBKEY_SHA256=33ac1d9b9e56005ccac045eac2398b3e9dd6b3f5b66ae6260f2d478c7c0d82c8
SERIAL=c170fbf3bf27481e5c351a4db6f2dc5f
SUBJECT_DN=CN=sslmate.com
SUMMARY='certificate discovered for .sslmate.com'
TBS_SHA256=2388ee81c6f45cffc73e68a35fa8921e839e20acc9a98e8e6dcaea07cbfbdef8
TEXT_FILENAME=/usr2/andrew/.certspotter/certs/3c/3cdc83b3932c194fcdf17aa2bf1abc34e8438b293c3d5c70693e175b38ff128a.txt
WATCH_ITEM=.sslmate.com
example JSON file for a discovered certificate:
{
"dns_names": [
"sslmate.com",
"www.sslmate.com"
],
"ip_addresses": [],
"not_after": "2024-01-26T03:47:26Z",
"not_before": "2023-01-31T03:47:26Z",
"pubkey_sha256": "33ac1d9b9e56005ccac045eac2398b3e9dd6b3f5b66ae6260f2d478c7c0d82c8",
"tbs_sha256": "2388ee81c6f45cffc73e68a35fa8921e839e20acc9a98e8e6dcaea07cbfbdef8"
}
π SEE ALSO π
certspotter(8) β your other half, go read it fr fr
π COPYRIGHT π
Copyright Β© 2016-2023 Opsmate, Inc. β iconic, protected, periodt π
π BUGS π
report bugs to https://github.com/SSLMate/certspotter. they want to hear from you bestie, don't be shy π«Ά
and that's a wrap on certspotter-script(8) from 2026-01-14 π go forth and hook your scripts, you absolute legend ππ§ββοΈ
π¦ where this page comes from
- ubuntu resolute: certspotter 0.18.0-1build1 Β· MPL-2.0
- ubuntu stonking: certspotter 0.18.0-1build1 Β· MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms