-
Notifications
You must be signed in to change notification settings - Fork 5
/
context_test.go
76 lines (71 loc) · 3.33 KB
/
context_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package gossl
import (
"testing"
"github.com/shanemhansen/gossl/crypto/evp"
"github.com/shanemhansen/gossl/crypto/x509"
)
func TestContext(t *testing.T) {
c := NewContext(SSLv3Method())
pkey, err := evp.LoadPrivateKeyPEM(key_pem)
cert, err := x509.ParseCertificatePEM(cert_pem)
if err != nil {
t.Fatal(err)
}
c.UsePrivateKey(pkey)
c.UseCertificate(cert)
err = c.CheckPrivateKey()
if err != nil {
t.Fatal(err)
}
c.SetVerify(VERIFY_NONE)
c.SetVerify(9)
c.GetCertStore()
// FIXME these are not tested after being set
}
var key_pem = []byte(`-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAvcl+PqBRBBnWCUwch9Yx/RSP2tGxMVo3FCQzcri3y/PldIJB
OK6Pyj92E/q+jUzcCPCruGZDp+fNj3vJ7/pnagP8UYNeh1jAIFTNm8xP0SkV8EiD
qQ1CJjpdksFl4N27Y+TpLuKh//bhvS1v+wQf4zArczz2AB0OXpCTvzqBoDneUMy+
9dHIoND+khMNhSG9EAHEz41k/kv6klqi/58a4GWBeSchPPQvmkzZ74i2LYV+S65j
qEurjSCIJ+gsR9TKlVIel6xsO716BhORWIvIsUsbq1bKPCZlBfDheSUKyKXZdxBt
4V8Qi4N0ya1aYmqpbU+DkvHHz6Ti+5AlpmEEswIDAQABAoIBAQC5H+20Ov8r5+O/
J+4AlnAmdMMp6DdWc7CcRf+lXQdzu5HLxy7FkokR+Ds+m+z5uco8Mj7e3WoLQ3Jh
DpfZLUFoyUB7ZpBzp5+pKe9xlKca2F/dBW7gHN20mmQiPeIZqVAbzf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