get_cipher_info¶
certmonitor.core.CertMonitor.get_cipher_info ¶
get_cipher_info() -> Dict[str, Any]
Retrieve and structure the cipher information of the SSL/TLS connection.
Source code in certmonitor/core.py
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | |
API Reference: CertMonitor¶
certmonitor.core.CertMonitor ¶
CertMonitor(host: str, port: int = 443, enabled_validators: Optional[List[str]] = None)
Class for monitoring and retrieving certificate details from a given host.
Initialize the CertMonitor with the specified host and port.
Source code in certmonitor/core.py
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 49 | |
enabled_validators
instance-attribute
¶
enabled_validators = enabled_validators if enabled_validators is not None else ENABLED_VALIDATORS
__enter__ ¶
__enter__() -> CertMonitor
Enter the runtime context related to this object.
Source code in certmonitor/core.py
51 52 53 54 | |
__exit__ ¶
__exit__(exc_type: Any, exc_value: Any, traceback: Any) -> None
Exit the runtime context related to this object.
Source code in certmonitor/core.py
56 57 58 | |
close ¶
close() -> None
Close the connection and reset the handler.
Source code in certmonitor/core.py
96 97 98 99 100 | |
connect ¶
connect() -> Optional[Dict[str, Any]]
Establishes a connection to the host if not already connected.
Source code in certmonitor/core.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
describe_validators ¶
describe_validators() -> Dict[str, Dict[str, Any]]
Describe every registered validator and the user args it accepts.
Reads each validator's cached _user_params (built by
BaseCertValidator.__init_subclass__ / BaseCipherValidator.__init_subclass__
at class definition time) and renders a serializable description suitable
for printing, logging, or feeding into a CLI --help page.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict[str, Dict[str, Any]]
|
Keyed by validator name. Each value contains:
|
Example
with CertMonitor("example.com") as monitor:
for name, info in monitor.describe_validators().items():
print(name, info["args"])
Source code in certmonitor/core.py
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | |
detect_protocol ¶
detect_protocol() -> Union[str, Dict[str, Any]]
Detect the protocol used by the host.
Source code in certmonitor/core.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
get_cert_info ¶
get_cert_info() -> Dict[str, Any]
Retrieves and structures the certificate details.
Source code in certmonitor/core.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_cipher_info ¶
get_cipher_info() -> Dict[str, Any]
Retrieve and structure the cipher information of the SSL/TLS connection.
Source code in certmonitor/core.py
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | |
get_enabled_validators ¶
get_enabled_validators() -> List[str]
Get the list of validators enabled for this CertMonitor instance.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: A list of enabled validator names for this instance. |
Source code in certmonitor/core.py
710 711 712 713 714 715 716 717 718 719 | |
get_public_key_der ¶
get_public_key_der() -> Union[bytes, Dict[str, Any], None]
Return the public key in DER format.
Source code in certmonitor/core.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |
get_public_key_pem ¶
get_public_key_pem() -> Union[str, Dict[str, Any], None]
Return the public key in PEM format.
Source code in certmonitor/core.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | |
get_raw_der ¶
get_raw_der() -> Union[bytes, Dict[str, Any]]
Return the raw DER format of the certificate.
Source code in certmonitor/core.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | |
get_raw_pem ¶
get_raw_pem() -> Union[str, Dict[str, Any]]
Return the raw PEM format of the certificate.
Source code in certmonitor/core.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
list_validators ¶
list_validators() -> List[str]
Get a list of all available validators that can be used.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: A list of all registered validator names. |
Source code in certmonitor/core.py
721 722 723 724 725 726 727 728 729 730 | |
validate ¶
validate(validator_args: Optional[Dict[str, Any]] = None) -> Dict[str, Any]
Validates the target host by running all enabled validators.
This method: 1. Checks if all requested validators are implemented. 2. Separates validators into cert-based and cipher-based groups. 3. Fetches cert_info and cipher_info as needed. 4. Runs each validator with the appropriate arguments. 5. Returns a dictionary of validation results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
validator_args
|
dict
|
Additional arguments for specific validators. Example: { "subject_alt_names": ["example.com", "test.com"] } |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict[str, Any]
|
A dictionary keyed by validator name, each value being the result of that validator. |
Example
results = monitor.validate() print(results["expiration"]) # Output for expiration validator print(results["weak_cipher"]) # Output for weak cipher validator
Source code in certmonitor/core.py
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |