Copy of github.com/askrobots/network-computer (MIT): a desk you reach from anything. The original lives on GitHub.

2 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/demo/network-computer.git
HTTPS
https://gitstable.com/git/demo/network-computer.git
SSH
ssh://git@gitstable.com:2222/demo/network-computer.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

GitStable demo README: say this is a copy and where the original is cde82c2 13 hours, 42 minutes ago History
tlspin_test.go · 1023 bytes · 41 lines
1package tlspin
2
3import (
4 "crypto/sha256"
5 "encoding/hex"
6 "net/http"
7 "net/http/httptest"
8 "testing"
9)
10
11func TestPinning(t *testing.T) {
12 srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
13 w.Write([]byte("ok"))
14 }))
15 defer srv.Close()
16 sum := sha256.Sum256(srv.Certificate().Raw)
17 good := hex.EncodeToString(sum[:])
18
19 if _, err := Client(good).Get(srv.URL); err != nil {
20 t.Fatalf("correct pin rejected: %v", err)
21 }
22 // uppercase with colons, as people copy it
23 colons := ""
24 for i := 0; i < len(good); i += 2 {
25 if i > 0 {
26 colons += ":"
27 }
28 colons += good[i : i+2]
29 }
30 if _, err := Client("SHA256 " + colons).Get(srv.URL); err != nil {
31 t.Fatalf("normalised pin rejected: %v", err)
32 }
33 bad := "00" + good[2:]
34 if _, err := Client(bad).Get(srv.URL); err == nil {
35 t.Fatal("wrong pin accepted")
36 }
37 // unpinned client must still refuse a self-signed cert
38 if _, err := Client("").Get(srv.URL); err == nil {
39 t.Fatal("unpinned client accepted a self-signed cert")
40 }
41}