---
slug: "python3-13-ssl-basic-constraints-critical-alert-ignore"
title: "Python3.13 で VERIFY_X509_STRICT により Basic Constraints が Critical でない場合の自己署名証明書を使った時にエラーを出さない方法"
description: "Python3.13 で、自己署名証明書を使っているサーバーにリクエストする際の httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Basic Constraints of CA cert not marked critical (_ssl.c:1020) のエラーの回避方法です。"
url: "https://www.ytyng.com/blog/python3-13-ssl-basic-constraints-critical-alert-ignore"
publish_date: "2025-05-21T02:50:31Z"
created: "2025-05-21T02:50:31.267Z"
updated: "2026-04-20T01:19:28.722Z"
categories: ["Python"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20250521/62707007f0854076bd19dfa4ddb1ddac.png.webp?width=768"
has_video: true
has_music: true
video_urls: ["https://media.ytyng.net/ytyng-blog/321/featured-video-1.mp4", "https://media.ytyng.net/ytyng-blog/321/featured-video-2.mp4", "https://media.ytyng.net/ytyng-blog/321/featured-video-3.mp4"]
music_urls: ["https://media.ytyng.net/ytyng-blog/321/featured-music-321-3.mp3", "https://media.ytyng.net/ytyng-blog/321/featured-music-321-5.mp3"]
lang: "ja"
---

# Python3.13 で VERIFY_X509_STRICT により Basic Constraints が Critical でない場合の自己署名証明書を使った時にエラーを出さない方法

_注意: この記事は、本来デフォルトで設定されているセキュリティ水準を意図的に下げる内容が書かれています。リスクを理解し、リスクを許容できる環境下でのみ実施してください。_


自己署名のSSL証明書を使ったHTTPサーバーに対して、 Python の Requests や httpx でリクエストしようとした場合、


```python
import httpx

ca_file_path = os.path.join(os.path.dirname(__file__), 'my-ca.crt')
content = httpx.get('https://my-internal-server.example.com/', verify=ca_file_path)
```

```python
import requests

ca_file_path = os.path.join(os.path.dirname(__file__), 'my-ca.crt')

response = requests.get('https://my-internal-server.example.com/', verify=ca_file_path)
```

このようなコードになります。

Python3.12 までは問題ありませんが、 Python3.13 の場合、CA 証明書の `X509v3 Basic Constraints` が Critical になっていない場合は

```
httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Basic Constraints of CA cert not marked critical (_ssl.c:1020)
```
このエラーが出てしまいます。

Python3.13 で、かつ CA 証明書を修正せず、とりいそぎエラーを回避したい場合は

```python
import httpx
import ssl

ca_file_path = os.path.join(os.path.dirname(__file__), 'my-ca.crt')

context = ssl.create_default_context()
context.verify_flags &= ~ssl.VERIFY_X509_STRICT
context.load_verify_locations(ca_file_path)

response = httpx.get('https://my-internal-server.example.com/', verify=context)
```

これで回避できます。

_※ 脆弱です_
