Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/guide/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ from wreq.tls import KeyLog


async def main():
client = Client(keylog=KeyLog.file("keylog.log"))
client = Client(tls_keylog=KeyLog.file("keylog.log"))
resp = await client.get("https://www.google.com")
async with resp:
print(await resp.text())
Expand Down
2 changes: 1 addition & 1 deletion docs/source/guide/websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def recv_message(ws):

async def main():
# Connect to HTTP/2 WebSocket server with force_http2=True
client = wreq.Client(verify=False)
client = wreq.Client(tls_verify=False)
ws: WebSocket = await client.websocket(
"wss://127.0.0.1:3000/ws",
force_http2=True
Expand Down
2 changes: 1 addition & 1 deletion examples/http2_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def recv_message(ws):


async def main():
client = wreq.Client(verify=False)
client = wreq.Client(tls_verify=False)
ws: WebSocket = await client.websocket("wss://127.0.0.1:3000/ws", force_http2=True)
async with ws:
print("Status Code: ", ws.status)
Expand Down
2 changes: 1 addition & 1 deletion examples/keylog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


async def main():
client = Client(keylog=KeyLog.file("keylog.log"))
client = Client(tls_keylog=KeyLog.file("keylog.log"))
resp = await client.get("https://www.google.com")
async with resp:
print(await resp.text())
Expand Down
8 changes: 4 additions & 4 deletions python/wreq/wreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,22 +675,22 @@ class ClientConfig(TypedDict):

# ======== TLS options ========

verify: NotRequired[bool | Path | CertStore]
tls_verify: NotRequired[bool | Path | CertStore]
"""
Sets whether to verify TLS certificates.
"""

verify_hostname: NotRequired[bool]
tls_verify_hostname: NotRequired[bool]
"""
Configures the use of hostname verification when connecting.
"""

identity: NotRequired[Identity]
tls_identity: NotRequired[Identity]
"""
Represents a private key and X509 cert as a client certificate.
"""

keylog: NotRequired[KeyLog]
tls_keylog: NotRequired[KeyLog]
"""
Key logging policy (environment or file).
"""
Expand Down
24 changes: 12 additions & 12 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ struct Builder {

// ========= TLS options =========
/// Whether to verify the SSL certificate or root certificate file path.
verify: Option<TlsVerify>,
tls_verify: Option<TlsVerify>,
/// Whether to verify the hostname in the SSL certificate.
verify_hostname: Option<bool>,
tls_verify_hostname: Option<bool>,
/// Represents a private key and X509 cert as a client certificate.
identity: Option<Identity>,
tls_identity: Option<Identity>,
/// Key logging policy for TLS session keys.
keylog: Option<KeyLog>,
tls_keylog: Option<KeyLog>,
/// Add TLS information as `TlsInfo` extension to responses.
tls_info: Option<bool>,
/// The minimum TLS version to use for the client.
Expand Down Expand Up @@ -211,10 +211,10 @@ impl FromPyObject<'_, '_> for Builder {
extract_option!(ob, builder, http1_options);
extract_option!(ob, builder, http2_options);

extract_option!(ob, builder, verify);
extract_option!(ob, builder, verify_hostname);
extract_option!(ob, builder, identity);
extract_option!(ob, builder, keylog);
extract_option!(ob, builder, tls_verify);
extract_option!(ob, builder, tls_verify_hostname);
extract_option!(ob, builder, tls_identity);
extract_option!(ob, builder, tls_keylog);
extract_option!(ob, builder, tls_info);
extract_option!(ob, builder, min_tls_version);
extract_option!(ob, builder, max_tls_version);
Expand Down Expand Up @@ -388,13 +388,13 @@ impl Client {
apply_option!(
set_if_some,
builder,
config.verify_hostname,
config.tls_verify_hostname,
verify_hostname
);
apply_option!(set_if_some_inner, builder, config.identity, identity);
apply_option!(set_if_some_inner, builder, config.keylog, keylog);
apply_option!(set_if_some_inner, builder, config.tls_identity, identity);
apply_option!(set_if_some_inner, builder, config.tls_keylog, keylog);
apply_option!(set_if_some_inner, builder, config.tls_options, tls_options);
if let Some(verify) = config.verify.take() {
if let Some(verify) = config.tls_verify.take() {
builder = match verify {
TlsVerify::Verification(verify) => builder.cert_verification(verify),
TlsVerify::CertificatePath(path_buf) => {
Expand Down
6 changes: 3 additions & 3 deletions tests/tls_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@pytest.mark.asyncio
@pytest.mark.flaky(reruns=3, reruns_delay=2)
async def test_badssl():
client = wreq.Client(verify=False)
client = wreq.Client(tls_verify=False)
resp = await client.get("https://self-signed.badssl.com/")
async with resp:
assert resp.status.is_success()
Expand All @@ -17,7 +17,7 @@ async def test_badssl():
@pytest.mark.flaky(reruns=3, reruns_delay=2)
async def test_badssl_invalid_cert():
url = "https://self-signed.badssl.com/"
client = wreq.Client(verify=False, tls_info=True)
client = wreq.Client(tls_verify=False, tls_info=True)
resp = await client.get(url)
async with resp:
assert resp.status.is_success()
Expand All @@ -33,7 +33,7 @@ async def test_badssl_invalid_cert():
cert_store = CertStore(der_certs=[peer_der_cert])
assert cert_store is not None

client = wreq.Client(verify=cert_store)
client = wreq.Client(tls_verify=cert_store)
resp = await client.get(url)
async with resp:
assert resp.status.is_success()
Expand Down
Loading