샘플
truststore 0.10.4: SSLContext, inject_into_ssl
검증된 샘플 — pypi truststore 0.10.4: SSLContext, inject_into_ssl. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다…
sha256:5f5a9acf6f496920a2269f88ff878163b8bf2b668315fc93b45129b585bb407e
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
python linux 24 · ubuntu · glibc 2.39 x64 python python pip
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962… |
2026-08-28 |
케이스
HOW- 목표
- verify pkg:pypi/truststore@0.10.4
- 심벌
-
- truststore.SSLContext
- truststore.inject_into_ssl
- 환경
- python
- 생성일
- 2026-08-28T08:48:35Z
컨트랙트
- truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT) initializes an SSLContext configured with default client security settings (check_hostname=True, CERT_REQUIRED).
- truststore.SSLContext allows configuring TLS versions and verification options including minimum_version, maximum_version, check_hostname, and verify_mode.
- truststore.SSLContext raises NotImplementedError on cert_store_stats() and get_ca_certs() because system certificate stores are dynamic.
- truststore.inject_into_ssl() replaces ssl.SSLContext so that ssl.create_default_context() creates truststore.SSLContext instances.
- truststore.extract_from_ssl() restores ssl.SSLContext to the original standard library implementation.
- truststore.SSLContext.wrap_bio() creates an ssl.SSLObject wrapping memory BIO streams.
파일
- NOTES.md
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
소스
# truststore SSLContext and inject_into_ssl API
This sample pins `truststore` 0.10.4 and verifies `truststore.SSLContext`, `truststore.inject_into_ssl`, and `truststore.extract_from_ssl` for native system certificate verification.
The contract verifies:
- `truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)` instantiates a client context with `check_hostname=True` and `verify_mode=ssl.CERT_REQUIRED`.
- Context configuration properties such as `minimum_version`, `maximum_version`, `check_hostname`, and `verify_mode` can be modified.
- `cert_store_stats()` and `get_ca_certs()` raise `NotImplementedError` as system trust stores are evaluated dynamically.
- `truststore.inject_into_ssl()` replaces `ssl.SSLContext` with `truststore.SSLContext` so that `ssl.create_default_context()` produces `truststore.SSLContext` instances.
- `truststore.extract_from_ssl()` restores the original `ssl.SSLContext` class.
- `wrap_bio()` constructs an `ssl.SSLObject` around standard `ssl.MemoryBIO` buffers.
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:pypi/truststore@0.10.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/truststore@0.10.4
Demonstrate these symbols/APIs:
- truststore.SSLContext
- truststore.inject_into_ssl
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:a22f9f6953011d86a68b4f9a4b3e064745c1b057ef51519f8a0aac6cded2ccd8","contract":["truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT) initializes an SSLContext configured with default client security settings (check_hostname=True, CERT_REQUIRED).","truststore.SSLContext allows configuring TLS versions and verification options including minimum_version, maximum_version, check_hostname, and verify_mode.","truststore.SSLContext raises NotImplementedError on cert_store_stats() and get_ca_certs() because system certificate stores are dynamic.","truststore.inject_into_ssl() replaces ssl.SSLContext so that ssl.create_default_context() creates truststore.SSLContext instances.","truststore.extract_from_ssl() restores ssl.SSLContext to the original standard library implementation.","truststore.SSLContext.wrap_bio() creates an ssl.SSLObject wrapping memory BIO streams."],"goal":"verify pkg:pypi/truststore@0.10.4","kind":"HOW","packages":["pkg:pypi/truststore@0.10.4"],"schemaVersion":1,"symbols":["truststore.SSLContext","truststore.inject_into_ssl"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/truststore@0.10.4"],"schemaVersion":1,"subject":"pkg:pypi/truststore@0.10.4","symbols":["truststore.SSLContext","truststore.inject_into_ssl"],"verifierAdapter":"python@1"}
truststore==0.10.4
{
"schemaVersion": 1,
"goal": "verify pkg:pypi/truststore@0.10.4",
"kind": "HOW",
"packages": [
"pkg:pypi/truststore@0.10.4"
],
"symbols": [
"truststore.SSLContext",
"truststore.inject_into_ssl"
]
}
import ssl
import truststore
# 1. Verify truststore.SSLContext initializes with client defaults
ctx = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
assert isinstance(ctx, truststore.SSLContext), f"Expected truststore.SSLContext, got {type(ctx)}"
assert ctx.check_hostname is True, "Expected check_hostname to be True by default"
assert ctx.verify_mode == ssl.CERT_REQUIRED, f"Expected CERT_REQUIRED, got {ctx.verify_mode}"
# 2. Verify setting configuration properties on SSLContext
ctx.minimum_version = ssl.TLSVersion.TLSv1_2
assert ctx.minimum_version == ssl.TLSVersion.TLSv1_2, "Expected minimum_version to be TLSv1_2"
ctx.maximum_version = ssl.TLSVersion.TLSv1_3
assert ctx.maximum_version == ssl.TLSVersion.TLSv1_3, "Expected maximum_version to be TLSv1_3"
ctx.check_hostname = False
assert ctx.check_hostname is False, "Expected check_hostname to be False after update"
ctx.verify_mode = ssl.CERT_NONE
assert ctx.verify_mode == ssl.CERT_NONE, "Expected verify_mode to be CERT_NONE after update"
# 3. Verify methods unsupported by dynamic system trust store raise NotImplementedError
try:
ctx.cert_store_stats()
raise AssertionError("Expected cert_store_stats to raise NotImplementedError")
except NotImplementedError:
pass
try:
ctx.get_ca_certs()
raise AssertionError("Expected get_ca_certs to raise NotImplementedError")
except NotImplementedError:
pass
# 4. Verify inject_into_ssl replaces ssl.SSLContext
original_ssl_context = ssl.SSLContext
try:
truststore.inject_into_ssl()
assert ssl.SSLContext is truststore.SSLContext, "Expected ssl.SSLContext to be truststore.SSLContext"
injected_ctx = ssl.create_default_context()
assert isinstance(injected_ctx, truststore.SSLContext), "Expected create_default_context to return truststore.SSLContext"
finally:
# 5. Verify extract_from_ssl restores ssl.SSLContext
truststore.extract_from_ssl()
assert ssl.SSLContext is original_ssl_context, "Expected ssl.SSLContext to be restored to original class"
restored_ctx = ssl.create_default_context()
assert not isinstance(restored_ctx, truststore.SSLContext), "Expected create_default_context to no longer return truststore.SSLContext"
# 6. Verify wrap_bio constructs an SSLObject
bio_in = ssl.MemoryBIO()
bio_out = ssl.MemoryBIO()
client_ctx = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_obj = client_ctx.wrap_bio(bio_in, bio_out, server_hostname="example.com")
assert isinstance(ssl_obj, ssl.SSLObject), f"Expected ssl.SSLObject, got {type(ssl_obj)}"
print("CONTRACT PASS: truststore.SSLContext and inject_into_ssl verified offline")
오리진 시더
익명