|
87 | 87 | QueryStatus, |
88 | 88 | ) |
89 | 89 | from .converter import SnowflakeConverter |
| 90 | +from .crl import CRLConfig |
90 | 91 | from .cursor import LOG_MAX_QUERY_LENGTH, SnowflakeCursor, SnowflakeCursorBase |
91 | 92 | from .description import ( |
92 | 93 | CLIENT_NAME, |
@@ -438,7 +439,7 @@ def _get_private_bytes_from_file( |
438 | 439 | ), # Read timeout for CRL downloads in milliseconds |
439 | 440 | "crl_cache_validity_hours": ( |
440 | 441 | None, |
441 | | - (type(None), int), |
| 442 | + (type(None), float), |
442 | 443 | ), # CRL cache validity time in hours |
443 | 444 | "enable_crl_cache": (None, (type(None), bool)), # Enable CRL caching |
444 | 445 | "enable_crl_file_cache": (None, (type(None), bool)), # Enable file-based CRL cache |
@@ -592,6 +593,7 @@ def __init__( |
592 | 593 |
|
593 | 594 | # Placeholder attributes; will be initialized in connect() |
594 | 595 | self._http_config: HttpConfig | None = None |
| 596 | + self._crl_config: CRLConfig | None = None |
595 | 597 | self._session_manager: SessionManager | None = None |
596 | 598 | self._rest: SnowflakeRestful | None = None |
597 | 599 |
|
@@ -688,57 +690,81 @@ def _ocsp_mode(self) -> OCSPMode: |
688 | 690 | @property |
689 | 691 | def cert_revocation_check_mode(self) -> str | None: |
690 | 692 | """Certificate revocation check mode: DISABLED, ENABLED, or ADVISORY.""" |
691 | | - return self._cert_revocation_check_mode |
| 693 | + if not self._crl_config: |
| 694 | + return self._cert_revocation_check_mode |
| 695 | + return self._crl_config.cert_revocation_check_mode.value |
692 | 696 |
|
693 | 697 | @property |
694 | 698 | def allow_certificates_without_crl_url(self) -> bool | None: |
695 | 699 | """Whether to allow certificates without CRL distribution points.""" |
696 | | - return self._allow_certificates_without_crl_url |
| 700 | + if not self._crl_config: |
| 701 | + return self._allow_certificates_without_crl_url |
| 702 | + return self._crl_config.allow_certificates_without_crl_url |
697 | 703 |
|
698 | 704 | @property |
699 | 705 | def crl_connection_timeout_ms(self) -> int | None: |
700 | 706 | """Connection timeout for CRL downloads in milliseconds.""" |
701 | | - return self._crl_connection_timeout_ms |
| 707 | + if not self._crl_config: |
| 708 | + return self._crl_connection_timeout_ms |
| 709 | + return self._crl_config.connection_timeout_ms |
702 | 710 |
|
703 | 711 | @property |
704 | 712 | def crl_read_timeout_ms(self) -> int | None: |
705 | 713 | """Read timeout for CRL downloads in milliseconds.""" |
706 | | - return self._crl_read_timeout_ms |
| 714 | + if not self._crl_config: |
| 715 | + return self._crl_read_timeout_ms |
| 716 | + return self._crl_config.read_timeout_ms |
707 | 717 |
|
708 | 718 | @property |
709 | | - def crl_cache_validity_hours(self) -> int | None: |
| 719 | + def crl_cache_validity_hours(self) -> float | None: |
710 | 720 | """CRL cache validity time in hours.""" |
711 | | - return self._crl_cache_validity_hours |
| 721 | + if not self._crl_config: |
| 722 | + return self._crl_cache_validity_hours |
| 723 | + return self._crl_config.cache_validity_time.total_seconds() / 3600 |
712 | 724 |
|
713 | 725 | @property |
714 | 726 | def enable_crl_cache(self) -> bool | None: |
715 | 727 | """Whether CRL caching is enabled.""" |
716 | | - return self._enable_crl_cache |
| 728 | + if not self._crl_config: |
| 729 | + return self._enable_crl_cache |
| 730 | + return self._crl_config.enable_crl_cache |
717 | 731 |
|
718 | 732 | @property |
719 | 733 | def enable_crl_file_cache(self) -> bool | None: |
720 | 734 | """Whether file-based CRL cache is enabled.""" |
721 | | - return self._enable_crl_file_cache |
| 735 | + if not self._crl_config: |
| 736 | + return self._enable_crl_file_cache |
| 737 | + return self._crl_config.enable_crl_file_cache |
722 | 738 |
|
723 | 739 | @property |
724 | 740 | def crl_cache_dir(self) -> str | None: |
725 | 741 | """Directory for CRL file cache.""" |
726 | | - return self._crl_cache_dir |
| 742 | + if not self._crl_config: |
| 743 | + return self._crl_cache_dir |
| 744 | + if not self._crl_config.crl_cache_dir: |
| 745 | + return None |
| 746 | + return str(self._crl_config.crl_cache_dir) |
727 | 747 |
|
728 | 748 | @property |
729 | 749 | def crl_cache_removal_delay_days(self) -> int | None: |
730 | 750 | """Days to keep expired CRL files before removal.""" |
731 | | - return self._crl_cache_removal_delay_days |
| 751 | + if not self._crl_config: |
| 752 | + return self._crl_cache_removal_delay_days |
| 753 | + return self._crl_config.crl_cache_removal_delay_days |
732 | 754 |
|
733 | 755 | @property |
734 | 756 | def crl_cache_cleanup_interval_hours(self) -> int | None: |
735 | 757 | """CRL cache cleanup interval in hours.""" |
736 | | - return self._crl_cache_cleanup_interval_hours |
| 758 | + if not self._crl_config: |
| 759 | + return self._crl_cache_cleanup_interval_hours |
| 760 | + return self._crl_config.crl_cache_cleanup_interval_hours |
737 | 761 |
|
738 | 762 | @property |
739 | 763 | def crl_cache_start_cleanup(self) -> bool | None: |
740 | 764 | """Whether to start CRL cache cleanup immediately.""" |
741 | | - return self._crl_cache_start_cleanup |
| 765 | + if not self._crl_config: |
| 766 | + return self._crl_cache_start_cleanup |
| 767 | + return self._crl_config.crl_cache_start_cleanup |
742 | 768 |
|
743 | 769 | @property |
744 | 770 | def session_id(self) -> int: |
@@ -1041,6 +1067,8 @@ def connect(self, **kwargs) -> None: |
1041 | 1067 | if len(kwargs) > 0: |
1042 | 1068 | self.__config(**kwargs) |
1043 | 1069 |
|
| 1070 | + self._crl_config: CRLConfig = CRLConfig.from_connection(self) |
| 1071 | + |
1044 | 1072 | self._http_config = HttpConfig( |
1045 | 1073 | adapter_factory=ProxySupportAdapterFactory(), |
1046 | 1074 | use_pooling=(not self.disable_request_pooling), |
|
0 commit comments