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

🐛 fix certificate normalizer openssl rsa #292

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions boefjes/boefjes/plugins/kat_ssl_certificates/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from dateutil.parser import parse

import logging
from boefjes.job_models import NormalizerMeta
from octopoes.models import OOI, Reference
from octopoes.models.ooi.certificate import (
Expand Down Expand Up @@ -119,9 +119,10 @@ def read_certificates(
valid_until = cert.not_valid_after.isoformat()
pk_algorithm = ""
pk_size = cert.public_key().key_size
logging.info("Parsing certificate of type %s", type(cert.public_key()))
if isinstance(
cert.public_key(),
cryptography.hazmat.backends.openssl.x509.rsa.RSAPublicKey,
cryptography.hazmat.backends.openssl.rsa.RSAPublicKey,
):
pk_algorithm = str(AlgorithmType.RSA)
pk_number = cert.public_key().public_numbers().n.to_bytes(pk_size // 8, "big").hex()
Expand Down