44 lines
932 B
Plaintext
44 lines
932 B
Plaintext
== How to fix it in aiohttp
|
|
|
|
=== Code examples
|
|
|
|
include::../../common/fix/code-rationale.adoc[]
|
|
|
|
:cert_variable_name: verify_ssl
|
|
:cert_variable_unsafe_value: False
|
|
:cert_variable_safe_value: True
|
|
|
|
include::../../common/fix/code-rationale-setting.adoc[]
|
|
|
|
:cert_framework_context: aiohttp
|
|
|
|
include::../../common/fix/cert-hostname-validation-overlap.adoc[]
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,python,diff-id=41,diff-type=noncompliant]
|
|
----
|
|
import aiohttp
|
|
|
|
async def example():
|
|
async with aiohttp.ClientSession() as session:
|
|
session.get("https://example.com", verify_ssl=False) # Noncompliant
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,python,diff-id=41,diff-type=compliant]
|
|
----
|
|
import aiohttp
|
|
|
|
# By default, certificate validation is enabled
|
|
|
|
async def example():
|
|
async with aiohttp.ClientSession() as session:
|
|
session.get("https://example.com")
|
|
----
|
|
|
|
=== How does this work?
|
|
|
|
include::../../common/fix/validation.adoc[]
|