Skip to content

Commit b493e1c

Browse files
remove unused certificates and TLS configs
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
1 parent 4fee597 commit b493e1c

File tree

1 file changed

+4
-44
lines changed

1 file changed

+4
-44
lines changed

v2/transport/transport_auth.go

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ func BuildPluginTLSName(purpose string, moduleName string) string {
3333
}
3434

3535
type EphemeralTLSClient struct {
36-
caCert *x509.Certificate
37-
caPriv ed25519.PrivateKey
38-
tlsConfig *tls.Config
36+
caCert *x509.Certificate
37+
caPriv ed25519.PrivateKey
3938
}
4039

4140
func (s *EphemeralTLSClient) createCertPool() *x509.CertPool {
@@ -171,47 +170,8 @@ func NewEphemeralTLSClient() (*EphemeralTLSClient, error) {
171170
if err != nil {
172171
return nil, err
173172
}
174-
clientPub, clientPriv, err := ed25519.GenerateKey(rand.Reader)
175-
if err != nil {
176-
return nil, err
177-
}
178-
clientCertTemplate := &x509.Certificate{
179-
BasicConstraintsValid: true,
180-
Subject: pkix.Name{
181-
CommonName: ServerTLSName,
182-
},
183-
DNSNames: []string{
184-
ServerTLSName,
185-
},
186-
NotBefore: time.Now(),
187-
NotAfter: time.Now().Add(time.Hour * 24 * 365),
188-
KeyUsage: x509.KeyUsageDigitalSignature,
189-
ExtKeyUsage: []x509.ExtKeyUsage{
190-
x509.ExtKeyUsageClientAuth,
191-
},
192-
IsCA: false,
193-
}
194-
clientCertBytes, err := x509.CreateCertificate(rand.Reader, clientCertTemplate, caCert, clientPub, caPriv)
195-
if err != nil {
196-
return nil, err
197-
}
198-
certPool := x509.NewCertPool()
199-
certPool.AddCert(caCert)
200-
tlsConfig := &tls.Config{
201-
Certificates: []tls.Certificate{
202-
{
203-
Certificate: [][]byte{clientCertBytes},
204-
PrivateKey: clientPriv,
205-
},
206-
{
207-
Certificate: [][]byte{caCertBytes},
208-
},
209-
},
210-
RootCAs: certPool,
211-
}
212173
return &EphemeralTLSClient{
213-
caCert: caCert,
214-
caPriv: caPriv,
215-
tlsConfig: tlsConfig,
174+
caCert: caCert,
175+
caPriv: caPriv,
216176
}, nil
217177
}

0 commit comments

Comments
 (0)