loadKeyMaterials is a helper to read cert/key files from testdata and convert them into a KeyMaterialReader struct.
(t *testing.T, cert, key, ca string)
| 117 | // loadKeyMaterials is a helper to read cert/key files from testdata and convert |
| 118 | // them into a KeyMaterialReader struct. |
| 119 | func loadKeyMaterials(t *testing.T, cert, key, ca string) *KeyMaterial { |
| 120 | t.Helper() |
| 121 | |
| 122 | certs, err := tls.LoadX509KeyPair(testdata.Path(cert), testdata.Path(key)) |
| 123 | if err != nil { |
| 124 | t.Fatalf("Failed to load keyPair: %v", err) |
| 125 | } |
| 126 | |
| 127 | pemData, err := os.ReadFile(testdata.Path(ca)) |
| 128 | if err != nil { |
| 129 | t.Fatal(err) |
| 130 | } |
| 131 | roots := x509.NewCertPool() |
| 132 | roots.AppendCertsFromPEM(pemData) |
| 133 | return &KeyMaterial{Certs: []tls.Certificate{certs}, Roots: roots} |
| 134 | } |
| 135 | |
| 136 | // kmReader wraps the KeyMaterial method exposed by Provider and Distributor |
| 137 | // implementations. Defining the interface here makes it possible to use the |
no test coverage detected