-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest2.py
More file actions
48 lines (37 loc) · 1.55 KB
/
test2.py
File metadata and controls
48 lines (37 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import json
from certmonitor import CertMonitor
# Example usage
if __name__ == "__main__":
# Test with a hostname
validators = [
"subject_alt_names",
"expiration",
"hostname",
"root_certificate",
"key_info",
]
with CertMonitor("example.com", enabled_validators=validators) as monitor:
structured_cert = monitor.get_cert_info()
validation_results = monitor.validate()
# public_key_info = monitor._extract_public_key_info()
print("Hostname test:")
print(json.dumps(structured_cert, indent=2))
print("\n" + "=" * 50 + "\n")
print("Validation Results")
print(json.dumps(validation_results, indent=2))
print("\n" + "=" * 50 + "\n")
print("Cipher Results")
print(json.dumps(monitor.get_cipher_info(), indent=2))
print("\n" + "=" * 50 + "\n")
# Test the new public key extraction functionality
print("Public Key Information:")
print(f"Public Key DER available: {monitor.public_key_der is not None}")
print(f"Public Key PEM available: {monitor.public_key_pem is not None}")
if monitor.public_key_der:
print(f"Public Key DER length: {len(monitor.public_key_der)} bytes")
print(f"Public Key DER type: {type(monitor.public_key_der)}")
if monitor.public_key_pem:
print(f"Public Key PEM length: {len(monitor.public_key_pem)} characters")
print("Public Key PEM:")
print(monitor.public_key_pem)
print("\n" + "=" * 50 + "\n")