Skip to content

Commit

Permalink
Chore: update test key pairs & add tests for ECC certificate (p4gefau…
Browse files Browse the repository at this point in the history
  • Loading branch information
Loyalsoldier authored Sep 14, 2021
1 parent e28864f commit 6341a5e
Show file tree
Hide file tree
Showing 3 changed files with 465 additions and 203 deletions.
304 changes: 205 additions & 99 deletions api/service/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"os"
"testing"
"time"

Expand Down Expand Up @@ -157,7 +157,7 @@ func TestServerAPI(t *testing.T) {
cancel()
}

func TestTLS(t *testing.T) {
func TestTLSRSA(t *testing.T) {
port := common.PickPort("tcp", "127.0.0.1")
cfg := &Config{
API: APIConfig{
Expand All @@ -166,10 +166,10 @@ func TestTLS(t *testing.T) {
APIPort: port,
SSL: SSLConfig{
Enabled: true,
CertPath: "server.crt",
KeyPath: "server.key",
CertPath: "server-rsa2048.crt",
KeyPath: "server-rsa2048.key",
VerifyClient: false,
ClientCertPath: []string{"client.crt"},
ClientCertPath: []string{"client-rsa2048.crt"},
},
},
}
Expand All @@ -187,11 +187,11 @@ func TestTLS(t *testing.T) {
}()
time.Sleep(time.Second)
pool := x509.NewCertPool()
certBytes, err := ioutil.ReadFile("server.crt")
certBytes, err := os.ReadFile("server-rsa2048.crt")
common.Must(err)
pool.AppendCertsFromPEM(certBytes)

certificate, err := tls.LoadX509KeyPair("client.crt", "client.key")
certificate, err := tls.LoadX509KeyPair("client-rsa2048.crt", "client-rsa2048.key")
common.Must(err)
creds := credentials.NewTLS(&tls.Config{
ServerName: "localhost",
Expand All @@ -207,114 +207,220 @@ func TestTLS(t *testing.T) {
conn.Close()
}

var serverCert = `
func TestTLSECC(t *testing.T) {
port := common.PickPort("tcp", "127.0.0.1")
cfg := &Config{
API: APIConfig{
Enabled: true,
APIHost: "127.0.0.1",
APIPort: port,
SSL: SSLConfig{
Enabled: true,
CertPath: "server-ecc.crt",
KeyPath: "server-ecc.key",
VerifyClient: false,
ClientCertPath: []string{"client-ecc.crt"},
},
},
}

ctx := config.WithConfig(context.Background(), Name, cfg)
ctx = config.WithConfig(ctx, memory.Name,
&memory.Config{
Passwords: []string{},
})

auth, err := memory.NewAuthenticator(ctx)
common.Must(err)
go func() {
common.Must(RunServerAPI(ctx, auth))
}()
time.Sleep(time.Second)
pool := x509.NewCertPool()
certBytes, err := os.ReadFile("server-ecc.crt")
common.Must(err)
pool.AppendCertsFromPEM(certBytes)

certificate, err := tls.LoadX509KeyPair("client-ecc.crt", "client-ecc.key")
common.Must(err)
creds := credentials.NewTLS(&tls.Config{
ServerName: "localhost",
RootCAs: pool,
Certificates: []tls.Certificate{certificate},
})
conn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", port), grpc.WithTransportCredentials(creds))
common.Must(err)
server := NewTrojanServerServiceClient(conn)
stream, err := server.ListUsers(ctx, &ListUsersRequest{})
common.Must(err)
stream.CloseSend()
conn.Close()
}

var serverRSA2048Cert = `
-----BEGIN CERTIFICATE-----
MIIC+TCCAeGgAwIBAgIQAZ1MkNXl76ABOPPQ6ci25zANBgkqhkiG9w0BAQsFADAS
MRAwDgYDVQQKEwdBY21lIENvMB4XDTIwMDkwNjAzMTM1NVoXDTIxMDkwNjAzMTM1
NVowEjEQMA4GA1UEChMHQWNtZSBDbzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAJrgYRlmw0851xp1/OWN4b/gQsKc1TmTaMcN+gDX8w2RWfgOOGymeWDJ
QaTu1G6XHjuvW3sqZGixlRtUJKnmldiwpX0ZY00Ce15fgQHZ85uc3rnFjdkeaYFj
KXN7Xx0QZTQjR5N3W5oVvwKRXe9ATwtOKregSJxCMv8P6OWYH8SwR8GsZnUyvKYR
7JodTXpw7pIL4yNx+QETg537y0TXVFpVt0/H9OoKmY/vsIWVWkKOY4nre9XxNf/p
ABWxYy5n1CKTssLWblJs/lSSPfRxCKUnrBcHwr8ZvLwZSvVktLWr0DnurdfSXOSy
n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BggqhkjOPQMBBwNCAASvYy/r7XR1
Y39lC2JpRJh582zR2CTNynbuolK9a1jsbXaZv+hpBlHkgzMHsWu7LY9Pnb/Dbp4i
1lRASOddD/rLo4HOMIHLMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEF
BQcDAQYIKwYBBQUHAwIwHwYDVR0jBBgwFoAUWxGyVxD0fBhTy3tH4eKznRFXFCYw
YwYIKwYBBQUHAQEEVzBVMCEGCCsGAQUFBzABhhVodHRwOi8vb2NzcC5teXNzbC5j
b20wMAYIKwYBBQUHMAKGJGh0dHA6Ly9jYS5teXNzbC5jb20vbXlzc2x0ZXN0ZWNj
LmNydDAUBgNVHREEDTALgglsb2NhbGhvc3QwCgYIKoZIzj0EAwIDSAAwRQIgDQUa
GEdmKstLMHUmmPMGm/P9S4vvSZV2VHsb3+AEyIUCIQCdJpbyTCz+mEyskhwrGOw/
blh3WBONv6MBtqPpmgE1AQ==
-----END CERTIFICATE-----
`

var serverECCKey = `
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIB8G2suYKuBLoodNIwRMp3JPN1fcZxCt3kcOYIx4nbcPoAoGCCqGSM49
AwEHoUQDQgAEr2Mv6+10dWN/ZQtiaUSYefNs0dgkzcp27qJSvWtY7G12mb/oaQZR
5IMzB7Fruy2PT52/w26eItZUQEjnXQ/6yw==
-----END EC PRIVATE KEY-----
`

var clientECCCert = `
-----BEGIN CERTIFICATE-----
MIIC+jCCAeKgAwIBAgIRAJCepdWc3B+X+BMsoK9nJlAwDQYJKoZIhvcNAQELBQAw
EjEQMA4GA1UEChMHQWNtZSBDbzAeFw0yMDA5MDYwMzIyMzdaFw0yMTA5MDYwMzIy
MzdaMBIxEDAOBgNVBAoTB0FjbWUgQ28wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
ggEKAoIBAQDtp0CreAAU+8K9rz3e+XYcbf+WgVWOwD1+80g3ixHjUTnBDx4n+rAD
9UvVNMfMPBt65vxB3jBFk7BNeI6k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BBwNCAAQME+DnYtcK
lbcZmc33oEtoeRWH61DYdl4ei/bM+vkv01MkBB+YTZl0yofJIFJYsfU5pMFK+uyw
D4qdcklKPGIKo4HOMIHLMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEF
BQcDAQYIKwYBBQUHAwIwHwYDVR0jBBgwFoAUWxGyVxD0fBhTy3tH4eKznRFXFCYw
YwYIKwYBBQUHAQEEVzBVMCEGCCsGAQUFBzABhhVodHRwOi8vb2NzcC5teXNzbC5j
b20wMAYIKwYBBQUHMAKGJGh0dHA6Ly9jYS5teXNzbC5jb20vbXlzc2x0ZXN0ZWNj
LmNydDAUBgNVHREEDTALgglsb2NhbGhvc3QwCgYIKoZIzj0EAwIDSAAwRQIgfjaU
sCfgklPsjHzs3fUtSRGfWoRLFsRBO66RtHJSzrYCIQDAxgx0FB0mAXbflj4mXJVA
9/SjaCI40D6MhMnJhQS7Zg==
-----END CERTIFICATE-----
`

var clientECCKey = `
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEINgbap6WOGXm8V+ghIyporGcGWnggbjjP9xNsxhn+0sqoAoGCCqGSM49
AwEHoUQDQgAEDBPg52LXCpW3GZnN96BLaHkVh+tQ2HZeHov2zPr5L9NTJAQfmE2Z
dMqHySBSWLH1OaTBSvrssA+KnXJJSjxiCg==
-----END EC PRIVATE KEY-----
`

func init() {
ioutil.WriteFile("server.crt", []byte(serverCert), 0o777)
ioutil.WriteFile("server.key", []byte(serverKey), 0o777)
ioutil.WriteFile("client.crt", []byte(clientCert), 0o777)
ioutil.WriteFile("client.key", []byte(clientKey), 0o777)
os.WriteFile("server-rsa2048.crt", []byte(serverRSA2048Cert), 0o777)
os.WriteFile("server-rsa2048.key", []byte(serverRSA2048Key), 0o777)
os.WriteFile("client-rsa2048.crt", []byte(clientRSA2048Cert), 0o777)
os.WriteFile("client-rsa2048.key", []byte(clientRSA2048Key), 0o777)

os.WriteFile("server-ecc.crt", []byte(serverECCCert), 0o777)
os.WriteFile("server-ecc.key", []byte(serverECCKey), 0o777)
os.WriteFile("client-ecc.crt", []byte(clientECCCert), 0o777)
os.WriteFile("client-ecc.key", []byte(clientECCKey), 0o777)
}
Loading

0 comments on commit 6341a5e

Please sign in to comment.