@@ -113,67 +113,6 @@ <h4>Using trusted certificates</h4>
113
113
< h4 > Working with self-signed certificates or non-standard CAs</ h4 >
114
114
< p > In some cases, you might need to work with a server using a self-signed certificate, or a certificate issued by a CA not included in your trusted
115
115
roots. Rather than disabling certificate validation in your code, you can add the necessary certificates to your trust store.</ p >
116
- < h2 > How to fix it in HTTPX</ h2 >
117
- < h3 > Code examples</ h3 >
118
- < p > The following code contains examples of disabled certificate validation.</ p >
119
- < p > The certificate validation gets disabled by setting < code > verify</ code > to < code > False</ code > . To enable validation set the value to
120
- < code > True</ code > or do not set < code > verify</ code > at all to use the secure default value.</ p >
121
- < h4 > Noncompliant code example</ h4 >
122
- < pre data-diff-id ="31 " data-diff-type ="noncompliant ">
123
- import httpx
124
-
125
- httpx.get('https://example.com', verify=False) # Noncompliant
126
- </ pre >
127
- < h4 > Compliant solution</ h4 >
128
- < pre data-diff-id ="31 " data-diff-type ="compliant ">
129
- import httpx
130
-
131
- # By default, certificate validation is enabled
132
- httpx.get('https://example.com')
133
- </ pre >
134
- < h3 > How does this work?</ h3 >
135
- < p > Addressing the vulnerability of disabled TLS certificate validation primarily involves re-enabling the default validation.</ p >
136
- < p > To avoid running into problems with invalid certificates, consider the following sections.</ p >
137
- < h4 > Using trusted certificates</ h4 >
138
- < p > If possible, always use a certificate issued by a well-known, trusted CA for your server. Most programming environments come with a predefined list
139
- of trusted root CAs, and certificates issued by these authorities are validated automatically. This is the best practice, and it requires no
140
- additional code or configuration.</ p >
141
- < h4 > Working with self-signed certificates or non-standard CAs</ h4 >
142
- < p > In some cases, you might need to work with a server using a self-signed certificate, or a certificate issued by a CA not included in your trusted
143
- roots. Rather than disabling certificate validation in your code, you can add the necessary certificates to your trust store.</ p >
144
- < h2 > How to fix it in aiohttp</ h2 >
145
- < h3 > Code examples</ h3 >
146
- < p > The following code contains examples of disabled certificate validation.</ p >
147
- < p > The certificate validation gets disabled by setting < code > verify_ssl</ code > to < code > False</ code > . To enable validation set the value to
148
- < code > True</ code > or do not set < code > verify_ssl</ code > at all to use the secure default value.</ p >
149
- < h4 > Noncompliant code example</ h4 >
150
- < pre data-diff-id ="41 " data-diff-type ="noncompliant ">
151
- import aiohttp
152
-
153
- async def example():
154
- async with aiohttp.ClientSession() as session:
155
- session.get("https://example.com", verify_ssl=False) # Noncompliant
156
- </ pre >
157
- < h4 > Compliant solution</ h4 >
158
- < pre data-diff-id ="41 " data-diff-type ="compliant ">
159
- import aiohttp
160
-
161
- # By default, certificate validation is enabled
162
-
163
- async def example():
164
- async with aiohttp.ClientSession() as session:
165
- session.get("https://example.com")
166
- </ pre >
167
- < h3 > How does this work?</ h3 >
168
- < p > Addressing the vulnerability of disabled TLS certificate validation primarily involves re-enabling the default validation.</ p >
169
- < p > To avoid running into problems with invalid certificates, consider the following sections.</ p >
170
- < h4 > Using trusted certificates</ h4 >
171
- < p > If possible, always use a certificate issued by a well-known, trusted CA for your server. Most programming environments come with a predefined list
172
- of trusted root CAs, and certificates issued by these authorities are validated automatically. This is the best practice, and it requires no
173
- additional code or configuration.</ p >
174
- < h4 > Working with self-signed certificates or non-standard CAs</ h4 >
175
- < p > In some cases, you might need to work with a server using a self-signed certificate, or a certificate issued by a CA not included in your trusted
176
- roots. Rather than disabling certificate validation in your code, you can add the necessary certificates to your trust store.</ p >
177
116
< h2 > Resources</ h2 >
178
117
< h3 > Standards</ h3 >
179
118
< ul >
0 commit comments