Files
mesh-sdk/go/process/pin_test.go
T
jschoubben c61212eba7
mesh/repo-check head c61212eba77c merged into trunk c6e669f71e8e — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (typescript)…
mesh/merge-gate head c61212eba77c merged into trunk c6e669f71e8e — pass: group feat/r4d composed: every machine composes with the change as it did without …
mesh/delivery delivered
mesh/delivery-group group feat/r4d delivered: every member is delivered
mesh/check failed: unit: ..test: node:internal/modules/esm/resolve:241 | c61212eba77c on 5652312f09d2 | unit 1629 run, 0 kept, 3 skipped | integration…
Make the membership, its subject, stream, bare address and the pin public, so the route proxy leaves the controller's module (issue 1633)
2026-10-22 09:51:01 +02:00

24 lines
746 B
Go

package process
import (
"crypto/sha256"
"encoding/hex"
"testing"
)
// The pin accepts exactly the leaf certificate with the named SHA-256, and no other (novox/hq issue 1633).
func TestThePinAcceptsOnlyTheNamedCertificate(t *testing.T) {
leaf := []byte("a certificate")
sum := sha256.Sum256(leaf)
cfg := PinnedToFingerprint("sha256:" + hex.EncodeToString(sum[:]))
if err := cfg.VerifyPeerCertificate([][]byte{leaf}, nil); err != nil {
t.Errorf("the pinned certificate was refused: %v", err)
}
if err := cfg.VerifyPeerCertificate([][]byte{[]byte("another")}, nil); err == nil {
t.Error("another certificate was accepted")
}
if err := cfg.VerifyPeerCertificate(nil, nil); err == nil {
t.Error("no certificate was accepted")
}
}