Skip to content

feat(RELEASE-2031): Advanced certificate check script#671

Open
midnightercz wants to merge 2 commits intomainfrom
advanced-cert-check
Open

feat(RELEASE-2031): Advanced certificate check script#671
midnightercz wants to merge 2 commits intomainfrom
advanced-cert-check

Conversation

@midnightercz
Copy link
Contributor

Supports expiration, key-cert mismatch check, revocation check

@snyk-io
Copy link

snyk-io bot commented Mar 2, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@seanconroy2021
Copy link
Member

Hey, could you please update the commit and the PR title with the Jira?

@midnightercz
Copy link
Contributor Author

Hey, could you please update the commit and the PR title with the Jira?

Yeah, I hesitated as this one is not that much relevant to the JIRA where it came from. But I guess it doesn't matter that much and eventually one can find original reason why this was implemented

@midnightercz midnightercz changed the title feat: Advanced certificate check script feat(RELEASE-2031): Advanced certificate check script Mar 3, 2026
@midnightercz midnightercz force-pushed the advanced-cert-check branch 5 times, most recently from 4f611dc to 5ca6dd7 Compare March 3, 2026 09:05
Supports expiration, key-cert mismatch check, revocation check

Assisted-by: Claude

Signed-off-by: Jindrich Luza <jluza@redhat.com>
@midnightercz midnightercz force-pushed the advanced-cert-check branch from 5ca6dd7 to eeb8703 Compare March 3, 2026 09:12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if there was some description at the top, explaining what this script is and what it can do and also have some examples of usage.

Comment on lines +58 to +59
# with open(ca_path, "rb") as f:
# ca_cert = load_cert(ca_path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A remnant from testing? Should this be removed?

# If your key has a password, provide it in 'password='
private_key = serialization.load_pem_private_key(key_data, password=None)
# 3. Check if they match
# We compare the public key derived from the cert vs the one from the private key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I see "check cert", I assume it only works with certs. But this will definitely need the private key as well, right? Would it make sense to call this script check-key-cert or something similar then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it needs private key if you want to check cert+key mismatch. I'll put description on the top with examples and how it works for more clarity

"Accept": "application/ocsp-response",
}

response = requests.post(ocsp_url, data=ocsp_request_bytes, headers=headers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add a timeout here ?

# if issuer and CA was provided, we can also check OCSP status (revocation)

with open(issuer_path, "rb") as f:
issuer_cert = load_cert(issuer_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f is never used load_cert() reopens the file by path. So do we need with open?

)
parser.add_argument("--key", help="Path to the private key file (PEM format)")
parser.add_argument("--issuer", help="Path to the issuer certificate file (PEM format)")
parser.add_argument("--ca", help="Path to the CA certificate file (PEM format)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args.ca is never used anywhere

)
print(cert_info_result)
if is_valid:
print("Certification check succesfull", file=sys.stderr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

succesfull > successful

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.

3 participants