Beispiel
github.com/mholt/acmez/v3 v3.1.2: acme.ChallengeTypeTLSALPN01
Verifiziertes Beispiel für golang github.com/mholt/acmez/v3 v3.1.2: acme.ChallengeTypeTLSALPN01. Der Vertrag lief auf go 1.26 · linux alpine/x64 · docker und…
sha256:09b4df6af7a334911e93d4b7d38dc4935b343d43ba513ca88827b121f645fa58
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
go linux 24 · ubuntu · glibc 2.39 x64 go go go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
Fall
HOW- Ziel
- verify github.com/mholt/acmez/v3/acme.ChallengeTypeTLSALPN01 in pkg:golang/github.com/mholt/acmez/v3@v3.1.2
- Symbole
-
- github.com/mholt/acmez/v3/acme.ChallengeTypeTLSALPN01
- Umgebung
- go
- Erstellt
- 2026-08-28T01:36:43Z
Contract
- acme.ChallengeTypeTLSALPN01 evaluates to "tls-alpn-01" according to RFC 8737 §3.
- acme.Challenge with Type ChallengeTypeTLSALPN01 serializes to and deserializes from JSON preserving the challenge type and authorization metadata.
- acmez.TLSALPN01ChallengeCert generates a TLS certificate with the challenge identifier in DNSNames and an ECDSA P-256 private key.
- acmez.TLSALPN01ChallengeCert includes the critical acmeValidation-v1 extension containing the SHA-256 digest of keyAuthorization.
- TLS client and server configured with the generated challenge certificate and acmez.ACMETLS1Protocol complete a handshake negotiating "acme-tls/1".
- TLS client configured with an incompatible ALPN protocol fails to negotiate "acme-tls/1" against the challenge server.
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract_test.go
Quelltext
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 github.com/mholt/acmez/v3/acme.ChallengeTypeTLSALPN01 in pkg:golang/github.com/mholt/acmez/v3@v3.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/mholt/acmez/v3@v3.1.2
Demonstrate these symbols/APIs:
- github.com/mholt/acmez/v3/acme.ChallengeTypeTLSALPN01
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:800c9e9e639dcd4035bcb2302496cd91b7bb68a7b600f6e4c20c542d2f61b812","contract":["acme.ChallengeTypeTLSALPN01 evaluates to \"tls-alpn-01\" according to RFC 8737 §3.","acme.Challenge with Type ChallengeTypeTLSALPN01 serializes to and deserializes from JSON preserving the challenge type and authorization metadata.","acmez.TLSALPN01ChallengeCert generates a TLS certificate with the challenge identifier in DNSNames and an ECDSA P-256 private key.","acmez.TLSALPN01ChallengeCert includes the critical acmeValidation-v1 extension containing the SHA-256 digest of keyAuthorization.","TLS client and server configured with the generated challenge certificate and acmez.ACMETLS1Protocol complete a handshake negotiating \"acme-tls/1\".","TLS client configured with an incompatible ALPN protocol fails to negotiate \"acme-tls/1\" against the challenge server."],"goal":"verify github.com/mholt/acmez/v3/acme.ChallengeTypeTLSALPN01 in pkg:golang/github.com/mholt/acmez/v3@v3.1.2","kind":"HOW","packages":["pkg:golang/github.com/mholt/acmez/v3@v3.1.2"],"schemaVersion":1,"symbols":["github.com/mholt/acmez/v3/acme.ChallengeTypeTLSALPN01"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","executionContext":"go","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","runtime":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/mholt/acmez/v3@v3.1.2"],"schemaVersion":1,"subject":"pkg:golang/github.com/mholt/acmez/v3@v3.1.2","symbols":["github.com/mholt/acmez/v3/acme.ChallengeTypeTLSALPN01"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require github.com/mholt/acmez/v3 v3.1.2
require (
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/text v0.18.0 // indirect
)
github.com/mholt/acmez/v3 v3.1.2 h1:auob8J/0FhmdClQicvJvuDavgd5ezwLBfKuYmynhYzc=
github.com/mholt/acmez/v3 v3.1.2/go.mod h1:L1wOU06KKvq7tswuMDwKdcHeKpFFgkppZy/y0DFxagQ=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
package main
import (
"crypto/tls"
"fmt"
"log"
"github.com/mholt/acmez/v3"
"github.com/mholt/acmez/v3/acme"
)
func main() {
chal := acme.Challenge{
Type: acme.ChallengeTypeTLSALPN01,
Token: "dGVzdC10b2tlbg",
KeyAuthorization: "dGVzdC10b2tlbg.thumbprint123",
Identifier: acme.Identifier{
Type: "dns",
Value: "example.com",
},
}
fmt.Printf("Challenge Type: %s\n", chal.Type)
cert, err := acmez.TLSALPN01ChallengeCert(chal)
if err != nil {
log.Fatalf("failed to generate TLS-ALPN-01 challenge cert: %v", err)
}
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{*cert},
NextProtos: []string{acmez.ACMETLS1Protocol},
}
fmt.Printf("Configured TLS ALPN protocol: %s (cert count: %d)\n", tlsConfig.NextProtos[0], len(tlsConfig.Certificates))
}
{
"schemaVersion": 1,
"goal": "verify github.com/mholt/acmez/v3/acme.ChallengeTypeTLSALPN01 in pkg:golang/github.com/mholt/acmez/v3@v3.1.2",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/mholt/acmez/v3@v3.1.2"
],
"symbols": [
"github.com/mholt/acmez/v3/acme.ChallengeTypeTLSALPN01"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package test
import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/sha256"
"crypto/tls"
"crypto/x509"
"encoding/asn1"
"encoding/json"
"net"
"testing"
"time"
"github.com/mholt/acmez/v3"
"github.com/mholt/acmez/v3/acme"
)
// idPEACMEIdentifierV1 OID: 1.3.6.1.5.5.7.1.31 (RFC 8737 §6.1)
var idPEACMEIdentifierV1 = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 31}
func TestChallengeTypeTLSALPN01Constant(t *testing.T) {
if acme.ChallengeTypeTLSALPN01 != "tls-alpn-01" {
t.Fatalf("acme.ChallengeTypeTLSALPN01 = %q, want %q", acme.ChallengeTypeTLSALPN01, "tls-alpn-01")
}
}
func TestChallengeTypeTLSALPN01Serialization(t *testing.T) {
chal := acme.Challenge{
Type: acme.ChallengeTypeTLSALPN01,
URL: "https://example.com/acme/chall/123",
Status: "pending",
Token: "EVAhDYAs2MyAN-PnwSeAhA",
KeyAuthorization: "EVAhDYAs2MyAN-PnwSeAhA.TestThumbprintString123",
Identifier: acme.Identifier{
Type: "dns",
Value: "example.com",
},
}
data, err := json.Marshal(chal)
if err != nil {
t.Fatalf("json.Marshal failed: %v", err)
}
var parsed map[string]interface{}
if err := json.Unmarshal(data, &parsed); err != nil {
t.Fatalf("json.Unmarshal into map failed: %v", err)
}
if parsed["type"] != "tls-alpn-01" {
t.Errorf("expected json type %q, got %v", "tls-alpn-01", parsed["type"])
}
if parsed["token"] != "EVAhDYAs2MyAN-PnwSeAhA" {
t.Errorf("expected token %q, got %v", "EVAhDYAs2MyAN-PnwSeAhA", parsed["token"])
}
var roundtrip acme.Challenge
if err := json.Unmarshal(data, &roundtrip); err != nil {
t.Fatalf("json.Unmarshal roundtrip failed: %v", err)
}
if roundtrip.Type != acme.ChallengeTypeTLSALPN01 {
t.Errorf("roundtrip.Type = %q, want %q", roundtrip.Type, acme.ChallengeTypeTLSALPN01)
}
if roundtrip.KeyAuthorization != chal.KeyAuthorization {
t.Errorf("roundtrip.KeyAuthorization = %q, want %q", roundtrip.KeyAuthorization, chal.KeyAuthorization)
}
}
func TestTLSALPN01ChallengeCertProperties(t *testing.T) {
domain := "example.com"
keyAuth := "test-token-value.test-account-thumbprint"
chal := acme.Challenge{
Type: acme.ChallengeTypeTLSALPN01,
Token: "test-token-value",
KeyAuthorization: keyAuth,
Identifier: acme.Identifier{
Type: "dns",
Value: domain,
},
}
tlsCert, err := acmez.TLSALPN01ChallengeCert(chal)
if err != nil {
t.Fatalf("TLSALPN01ChallengeCert failed: %v", err)
}
if tlsCert == nil || len(tlsCert.Certificate) == 0 {
t.Fatal("expected non-empty tls.Certificate")
}
leaf, err := x509.ParseCertificate(tlsCert.Certificate[0])
if err != nil {
t.Fatalf("x509.ParseCertificate failed: %v", err)
}
// Verify SAN
if len(leaf.DNSNames) != 1 || leaf.DNSNames[0] != domain {
t.Errorf("leaf.DNSNames = %v, want [%s]", leaf.DNSNames, domain)
}
// Verify ECDSA P-256 key
privKey, ok := tlsCert.PrivateKey.(*ecdsa.PrivateKey)
if !ok {
t.Fatalf("expected *ecdsa.PrivateKey, got %T", tlsCert.PrivateKey)
}
if privKey.Curve != elliptic.P256() {
t.Errorf("expected elliptic.P256 curve, got %v", privKey.Curve.Params().Name)
}
// Verify acmeValidation-v1 extension
expectedDigest := sha256.Sum256([]byte(keyAuth))
var foundExt bool
for _, ext := range leaf.Extensions {
if ext.Id.Equal(idPEACMEIdentifierV1) {
foundExt = true
if !ext.Critical {
t.Errorf("expected idPEACMEIdentifierV1 extension to be marked critical")
}
var val []byte
if rest, err := asn1.Unmarshal(ext.Value, &val); err != nil || len(rest) > 0 {
t.Fatalf("failed to unmarshal extension ASN.1 value: %v", err)
}
if !bytes.Equal(val, expectedDigest[:]) {
t.Errorf("extension digest mismatch: got %x, want %x", val, expectedDigest[:])
}
break
}
}
if !foundExt {
t.Errorf("critical acmeValidation-v1 extension (%v) not found in certificate", idPEACMEIdentifierV1)
}
}
func TestTLSALPN01Handshake(t *testing.T) {
domain := "example.com"
keyAuth := "handshake-token.handshake-thumbprint"
chal := acme.Challenge{
Type: acme.ChallengeTypeTLSALPN01,
Token: "handshake-token",
KeyAuthorization: keyAuth,
Identifier: acme.Identifier{
Type: "dns",
Value: domain,
},
}
tlsCert, err := acmez.TLSALPN01ChallengeCert(chal)
if err != nil {
t.Fatalf("TLSALPN01ChallengeCert failed: %v", err)
}
serverConfig := &tls.Config{
Certificates: []tls.Certificate{*tlsCert},
NextProtos: []string{acmez.ACMETLS1Protocol},
}
clientConfig := &tls.Config{
InsecureSkipVerify: true,
ServerName: domain,
NextProtos: []string{acmez.ACMETLS1Protocol},
}
clientConn, serverConn := net.Pipe()
defer clientConn.Close()
defer serverConn.Close()
tlsServer := tls.Server(serverConn, serverConfig)
tlsClient := tls.Client(clientConn, clientConfig)
errChan := make(chan error, 2)
go func() {
errChan <- tlsServer.Handshake()
}()
go func() {
errChan <- tlsClient.Handshake()
}()
for i := 0; i < 2; i++ {
select {
case err := <-errChan:
if err != nil {
t.Fatalf("handshake failed: %v", err)
}
case <-time.After(5 * time.Second):
t.Fatal("handshake timed out")
}
}
clientState := tlsClient.ConnectionState()
if clientState.NegotiatedProtocol != acmez.ACMETLS1Protocol {
t.Errorf("client NegotiatedProtocol = %q, want %q", clientState.NegotiatedProtocol, acmez.ACMETLS1Protocol)
}
serverState := tlsServer.ConnectionState()
if serverState.NegotiatedProtocol != acmez.ACMETLS1Protocol {
t.Errorf("server NegotiatedProtocol = %q, want %q", serverState.NegotiatedProtocol, acmez.ACMETLS1Protocol)
}
}
func TestTLSALPN01ProtocolNegotiationMismatch(t *testing.T) {
chal := acme.Challenge{
Type: acme.ChallengeTypeTLSALPN01,
Token: "mismatch-token",
KeyAuthorization: "mismatch-token.thumbprint",
Identifier: acme.Identifier{
Type: "dns",
Value: "example.com",
},
}
tlsCert, err := acmez.TLSALPN01ChallengeCert(chal)
if err != nil {
t.Fatalf("TLSALPN01ChallengeCert failed: %v", err)
}
serverConfig := &tls.Config{
Certificates: []tls.Certificate{*tlsCert},
NextProtos: []string{acmez.ACMETLS1Protocol},
}
clientConfig := &tls.Config{
InsecureSkipVerify: true,
ServerName: "example.com",
NextProtos: []string{"http/1.1"},
}
clientConn, serverConn := net.Pipe()
defer clientConn.Close()
defer serverConn.Close()
tlsServer := tls.Server(serverConn, serverConfig)
tlsClient := tls.Client(clientConn, clientConfig)
errChan := make(chan error, 2)
go func() {
errChan <- tlsServer.Handshake()
}()
go func() {
errChan <- tlsClient.Handshake()
}()
for i := 0; i < 2; i++ {
select {
case err := <-errChan:
if err != nil {
// Handshake error is acceptable on protocol mismatch
return
}
case <-time.After(5 * time.Second):
t.Fatal("handshake timed out")
}
}
if tlsClient.ConnectionState().NegotiatedProtocol == acmez.ACMETLS1Protocol {
t.Errorf("did not expect client to negotiate %q when only offering http/1.1", acmez.ACMETLS1Protocol)
}
}
Ursprungs-Seeder
anonym