@@ -13,9 +13,9 @@ import (
1313 "time"
1414
1515 "github.com/stretchr/testify/require"
16+ "go.opentelemetry.io/collector/config/configtls"
1617
1718 "github.com/jaegertracing/jaeger/cmd/collector/app/flags"
18- "github.com/jaegertracing/jaeger/pkg/config/tlscfg"
1919 "github.com/jaegertracing/jaeger/pkg/tenancy"
2020 "github.com/jaegertracing/jaeger/pkg/testutils"
2121 "github.com/jaegertracing/jaeger/ports"
@@ -25,21 +25,21 @@ func TestSpanCollectorZipkinTLS(t *testing.T) {
2525 const testCertKeyLocation = "../../../../pkg/config/tlscfg/testdata"
2626 testCases := []struct {
2727 name string
28- serverTLS tlscfg. Options
29- clientTLS tlscfg. Options
28+ serverTLS configtls. ServerConfig
29+ clientTLS configtls. ClientConfig
3030 expectTLSClientErr bool
3131 expectZipkinClientErr bool
3232 expectServerFail bool
3333 }{
3434 {
3535 name : "should fail with TLS client to untrusted TLS server" ,
36- serverTLS : tlscfg.Options {
37- Enabled : true ,
38- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
39- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
36+ serverTLS : configtls.ServerConfig {
37+ Config : configtls.Config {
38+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
39+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
40+ },
4041 },
41- clientTLS : tlscfg.Options {
42- Enabled : true ,
42+ clientTLS : configtls.ClientConfig {
4343 ServerName : "example.com" ,
4444 },
4545 expectTLSClientErr : true ,
@@ -48,14 +48,16 @@ func TestSpanCollectorZipkinTLS(t *testing.T) {
4848 },
4949 {
5050 name : "should fail with TLS client to trusted TLS server with incorrect hostname" ,
51- serverTLS : tlscfg.Options {
52- Enabled : true ,
53- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
54- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
51+ serverTLS : configtls.ServerConfig {
52+ Config : configtls.Config {
53+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
54+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
55+ },
5556 },
56- clientTLS : tlscfg.Options {
57- Enabled : true ,
58- CAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
57+ clientTLS : configtls.ClientConfig {
58+ Config : configtls.Config {
59+ CAFile : testCertKeyLocation + "/example-CA-cert.pem" ,
60+ },
5961 ServerName : "nonEmpty" ,
6062 },
6163 expectTLSClientErr : true ,
@@ -64,14 +66,16 @@ func TestSpanCollectorZipkinTLS(t *testing.T) {
6466 },
6567 {
6668 name : "should pass with TLS client to trusted TLS server with correct hostname" ,
67- serverTLS : tlscfg.Options {
68- Enabled : true ,
69- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
70- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
69+ serverTLS : configtls.ServerConfig {
70+ Config : configtls.Config {
71+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
72+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
73+ },
7174 },
72- clientTLS : tlscfg.Options {
73- Enabled : true ,
74- CAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
75+ clientTLS : configtls.ClientConfig {
76+ Config : configtls.Config {
77+ CAFile : testCertKeyLocation + "/example-CA-cert.pem" ,
78+ },
7579 ServerName : "example.com" ,
7680 },
7781 expectTLSClientErr : false ,
@@ -80,78 +84,64 @@ func TestSpanCollectorZipkinTLS(t *testing.T) {
8084 },
8185 {
8286 name : "should fail with TLS client without cert to trusted TLS server requiring cert" ,
83- serverTLS : tlscfg.Options {
84- Enabled : true ,
85- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
86- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
87- ClientCAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
87+ serverTLS : configtls.ServerConfig {
88+ ClientCAFile : testCertKeyLocation + "/example-CA-cert.pem" ,
89+ Config : configtls.Config {
90+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
91+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
92+ },
8893 },
89- clientTLS : tlscfg.Options {
90- Enabled : true ,
91- CAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
94+ clientTLS : configtls.ClientConfig {
95+ Config : configtls.Config {
96+ CAFile : testCertKeyLocation + "/example-CA-cert.pem" ,
97+ },
9298 ServerName : "example.com" ,
9399 },
94100 expectTLSClientErr : false ,
95- expectServerFail : false ,
96101 expectZipkinClientErr : true ,
102+ expectServerFail : false ,
97103 },
98104 {
99105 name : "should pass with TLS client with cert to trusted TLS server requiring cert" ,
100- serverTLS : tlscfg.Options {
101- Enabled : true ,
102- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
103- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
104- ClientCAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
106+ serverTLS : configtls.ServerConfig {
107+ ClientCAFile : testCertKeyLocation + "/example-CA-cert.pem" ,
108+ Config : configtls.Config {
109+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
110+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
111+ },
105112 },
106- clientTLS : tlscfg.Options {
107- Enabled : true ,
108- CAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
113+ clientTLS : configtls.ClientConfig {
114+ Config : configtls.Config {
115+ CAFile : testCertKeyLocation + "/example-CA-cert.pem" ,
116+ CertFile : testCertKeyLocation + "/example-client-cert.pem" ,
117+ KeyFile : testCertKeyLocation + "/example-client-key.pem" ,
118+ },
109119 ServerName : "example.com" ,
110- CertPath : testCertKeyLocation + "/example-client-cert.pem" ,
111- KeyPath : testCertKeyLocation + "/example-client-key.pem" ,
112120 },
113121 expectTLSClientErr : false ,
114- expectServerFail : false ,
115122 expectZipkinClientErr : false ,
123+ expectServerFail : false ,
116124 },
117125 {
118- name : "should fail with TLS client without cert to trusted TLS server requiring cert from a different CA" ,
119- serverTLS : tlscfg.Options {
120- Enabled : true ,
121- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
122- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
123- ClientCAPath : testCertKeyLocation + "/wrong-CA-cert.pem" , // NB: wrong CA
126+ name : "should fail with TLS client without cert to trusted TLS server requiring cert from different CA" ,
127+ serverTLS : configtls.ServerConfig {
128+ ClientCAFile : testCertKeyLocation + "/wrong-CA-cert.pem" ,
129+ Config : configtls.Config {
130+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
131+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
132+ },
124133 },
125- clientTLS : tlscfg.Options {
126- Enabled : true ,
127- CAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
134+ clientTLS : configtls.ClientConfig {
135+ Config : configtls.Config {
136+ CAFile : testCertKeyLocation + "/example-CA-cert.pem" ,
137+ CertFile : testCertKeyLocation + "/example-client-cert.pem" ,
138+ KeyFile : testCertKeyLocation + "/example-client-key.pem" ,
139+ },
128140 ServerName : "example.com" ,
129- CertPath : testCertKeyLocation + "/example-client-cert.pem" ,
130- KeyPath : testCertKeyLocation + "/example-client-key.pem" ,
131141 },
132142 expectTLSClientErr : false ,
133- expectServerFail : false ,
134143 expectZipkinClientErr : true ,
135- },
136- {
137- name : "should fail with TLS client with cert to trusted TLS server with incorrect TLS min" ,
138- serverTLS : tlscfg.Options {
139- Enabled : true ,
140- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
141- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
142- ClientCAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
143- MinVersion : "1.5" ,
144- },
145- clientTLS : tlscfg.Options {
146- Enabled : true ,
147- CAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
148- ServerName : "example.com" ,
149- CertPath : testCertKeyLocation + "/example-client-cert.pem" ,
150- KeyPath : testCertKeyLocation + "/example-client-key.pem" ,
151- },
152- expectTLSClientErr : true ,
153- expectServerFail : true ,
154- expectZipkinClientErr : false ,
144+ expectServerFail : false ,
155145 },
156146 }
157147
@@ -163,7 +153,7 @@ func TestSpanCollectorZipkinTLS(t *testing.T) {
163153
164154 opts := & flags.CollectorOptions {}
165155 opts .Zipkin .Endpoint = ports .PortToHostPort (ports .CollectorZipkin )
166- opts .Zipkin .TLSSetting = test .serverTLS . ToOtelServerConfig ()
156+ opts .Zipkin .TLSSetting = & test .serverTLS
167157
168158 server , err := StartZipkinReceiver (opts , logger , spanProcessor , tm )
169159 if test .expectServerFail {
@@ -175,7 +165,7 @@ func TestSpanCollectorZipkinTLS(t *testing.T) {
175165 require .NoError (t , server .Shutdown (context .Background ()))
176166 }()
177167
178- clientTLSCfg , err0 := test .clientTLS .ToOtelClientConfig (). LoadTLSConfig (context .Background ())
168+ clientTLSCfg , err0 := test .clientTLS .LoadTLSConfig (context .Background ())
179169 require .NoError (t , err0 )
180170 dialer := & net.Dialer {Timeout : 2 * time .Second }
181171 conn , clientError := tls .DialWithDialer (dialer , "tcp" , fmt .Sprintf ("localhost:%d" , ports .CollectorZipkin ), clientTLSCfg )
0 commit comments