38 lines
1004 B
Plaintext
38 lines
1004 B
Plaintext
![]() |
include::../description.adoc[]
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
Python https://docs.python.org/3/library/ssl.html[ssl standard] library:
|
||
|
|
||
|
----
|
||
|
import ssl
|
||
|
|
||
|
ctx = ssl._create_unverified_context() # Noncompliant: by default hostname verification is not done
|
||
|
ctx = ssl._create_stdlib_context() # Noncompliant: by default hostname verification is not done
|
||
|
|
||
|
ctx = ssl.create_default_context()
|
||
|
ctx.check_hostname = False # Noncompliant
|
||
|
|
||
|
ctx = ssl._create_default_https_context()
|
||
|
ctx.check_hostname = False # Noncompliant
|
||
|
----
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
Python https://docs.python.org/3/library/ssl.html[ssl standard] library:
|
||
|
|
||
|
----
|
||
|
import ssl
|
||
|
|
||
|
ctx = ssl._create_unverified_context()
|
||
|
ctx.check_hostname = True # Compliant
|
||
|
|
||
|
ctx = ssl._create_stdlib_context()
|
||
|
ctx.check_hostname = True # Compliant
|
||
|
|
||
|
ctx = ssl.create_default_context() # Compliant: by default hostname verification is enabled
|
||
|
ctx = ssl._create_default_https_context() # Compliant: by default hostname verification is enabled
|
||
|
----
|
||
|
|
||
|
include::../see.adoc[]
|