(
ssl: Union["SSLContext", bool, Fingerprint],
verify_ssl: bool | None,
ssl_context: Optional["SSLContext"],
fingerprint: bytes | None,
)
| 174 | |
| 175 | |
| 176 | def _merge_ssl_params( |
| 177 | ssl: Union["SSLContext", bool, Fingerprint], |
| 178 | verify_ssl: bool | None, |
| 179 | ssl_context: Optional["SSLContext"], |
| 180 | fingerprint: bytes | None, |
| 181 | ) -> Union["SSLContext", bool, Fingerprint]: |
| 182 | if ssl is None: |
| 183 | ssl = True # Double check for backwards compatibility |
| 184 | if verify_ssl is not None and not verify_ssl: |
| 185 | warnings.warn( |
| 186 | "verify_ssl is deprecated, use ssl=False instead", |
| 187 | DeprecationWarning, |
| 188 | stacklevel=3, |
| 189 | ) |
| 190 | if ssl is not True: |
| 191 | raise ValueError( |
| 192 | "verify_ssl, ssl_context, fingerprint and ssl " |
| 193 | "parameters are mutually exclusive" |
| 194 | ) |
| 195 | else: |
| 196 | ssl = False |
| 197 | if ssl_context is not None: |
| 198 | warnings.warn( |
| 199 | "ssl_context is deprecated, use ssl=context instead", |
| 200 | DeprecationWarning, |
| 201 | stacklevel=3, |
| 202 | ) |
| 203 | if ssl is not True: |
| 204 | raise ValueError( |
| 205 | "verify_ssl, ssl_context, fingerprint and ssl " |
| 206 | "parameters are mutually exclusive" |
| 207 | ) |
| 208 | else: |
| 209 | ssl = ssl_context |
| 210 | if fingerprint is not None: |
| 211 | warnings.warn( |
| 212 | "fingerprint is deprecated, use ssl=Fingerprint(fingerprint) instead", |
| 213 | DeprecationWarning, |
| 214 | stacklevel=3, |
| 215 | ) |
| 216 | if ssl is not True: |
| 217 | raise ValueError( |
| 218 | "verify_ssl, ssl_context, fingerprint and ssl " |
| 219 | "parameters are mutually exclusive" |
| 220 | ) |
| 221 | else: |
| 222 | ssl = Fingerprint(fingerprint) |
| 223 | if not isinstance(ssl, SSL_ALLOWED_TYPES): |
| 224 | raise TypeError( |
| 225 | "ssl should be SSLContext, bool, Fingerprint or None, " |
| 226 | f"got {ssl!r} instead." |
| 227 | ) |
| 228 | return ssl |
| 229 | |
| 230 | |
| 231 | _SSL_SCHEMES = frozenset(("https", "wss")) |
searching dependent graphs…