Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_REQUIRED`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abbreviation. (So yo
(candidate: None | int | str)
| 139 | |
| 140 | |
| 141 | def resolve_cert_reqs(candidate: None | int | str) -> VerifyMode: |
| 142 | """ |
| 143 | Resolves the argument to a numeric constant, which can be passed to |
| 144 | the wrap_socket function/method from the ssl module. |
| 145 | Defaults to :data:`ssl.CERT_REQUIRED`. |
| 146 | If given a string it is assumed to be the name of the constant in the |
| 147 | :mod:`ssl` module or its abbreviation. |
| 148 | (So you can specify `REQUIRED` instead of `CERT_REQUIRED`. |
| 149 | If it's neither `None` nor a string we assume it is already the numeric |
| 150 | constant which can directly be passed to wrap_socket. |
| 151 | """ |
| 152 | if candidate is None: |
| 153 | return CERT_REQUIRED |
| 154 | |
| 155 | if isinstance(candidate, str): |
| 156 | res = getattr(ssl, candidate, None) |
| 157 | if res is None: |
| 158 | res = getattr(ssl, "CERT_" + candidate) |
| 159 | return res # type: ignore[no-any-return] |
| 160 | |
| 161 | return candidate # type: ignore[return-value] |
| 162 | |
| 163 | |
| 164 | def resolve_ssl_version(candidate: None | int | str) -> int: |
no outgoing calls