Skip to content

Commit 4b78a1d

Browse files
committed
refactor and remove unnecessary exttlsconfig
1 parent 142e7db commit 4b78a1d

File tree

3 files changed

+2
-52
lines changed

3 files changed

+2
-52
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,13 @@ If you just want to issue JWT's, see
5656

5757
### Usage TLS
5858

59-
see `example/mtls` folder
60-
6159
* for tpm see [mTLS with TPM bound private key](https://github.com/salrashid123/go_tpm_https_embed)
6260
* for kms see [mTLS with Google Cloud KMS](https://github.com/salrashid123/kms_golang_signer)
6361

6462

6563
### Sign/Verify PSS
6664

67-
see `example/sign_verify` folder
65+
see `example/sign_verify*` folders
6866

6967

7068
### Sign/Verify ECC

kms/kms.go

-23
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ type KMS struct {
3939
crypto.Signer // https://golang.org/pkg/crypto/#Signer
4040

4141
PublicKeyFile string
42-
ExtTLSConfig *tls.Config
4342
publicKey crypto.PublicKey
4443
ProjectId string
4544
LocationId string
@@ -62,15 +61,6 @@ func NewKMSCrypto(conf *KMS) (KMS, error) {
6261
if conf.ProjectId == "" {
6362
return KMS{}, fmt.Errorf("ProjectID cannot be null")
6463
}
65-
if conf.ExtTLSConfig != nil {
66-
if len(conf.ExtTLSConfig.Certificates) > 0 {
67-
return KMS{}, fmt.Errorf("certificates value in ExtTLSConfig Ignored")
68-
}
69-
70-
if len(conf.ExtTLSConfig.CipherSuites) > 0 {
71-
return KMS{}, fmt.Errorf("cipherSuites value in ExtTLSConfig Ignored")
72-
}
73-
}
7464
return *conf, nil
7565
}
7666

@@ -134,19 +124,6 @@ func (t KMS) TLSCertificate() tls.Certificate {
134124
}
135125
}
136126

137-
func (t KMS) TLSConfig() *tls.Config {
138-
return &tls.Config{
139-
Certificates: []tls.Certificate{t.TLSCertificate()},
140-
RootCAs: t.ExtTLSConfig.RootCAs,
141-
ClientCAs: t.ExtTLSConfig.ClientCAs,
142-
ClientAuth: t.ExtTLSConfig.ClientAuth,
143-
ServerName: t.ExtTLSConfig.ServerName,
144-
145-
CipherSuites: t.ExtTLSConfig.CipherSuites,
146-
MaxVersion: t.ExtTLSConfig.MaxVersion,
147-
}
148-
}
149-
150127
func (t KMS) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
151128
refreshMutex.Lock()
152129
defer refreshMutex.Unlock()

tpm/tpm.go

+1-26
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ type TPM struct {
4343
KeyHandle uint32 // path to the ptm device /dev/tpm0
4444
ECCRawOutput bool // for ECC keys, output raw signatures. If false, signature is ans1 formatted
4545
refreshMutex sync.Mutex
46-
PublicCertFile string // a provided public x509 certificate for the signer
47-
ExtTLSConfig *tls.Config // override tls.Config values
46+
PublicCertFile string // a provided public x509 certificate for the signer
4847
PCRs []int
4948

5049
x509Certificate x509.Certificate
@@ -70,15 +69,6 @@ func NewTPMCrypto(conf *TPM) (TPM, error) {
7069
if conf.TpmPath != "" && conf.KeyHandle == 0 {
7170
return TPM{}, fmt.Errorf("salrashid123/x/oauth2/google: if TPMTokenConfig.TPMPath is specified, a KeyHandle must be set")
7271
}
73-
if conf.ExtTLSConfig != nil {
74-
if len(conf.ExtTLSConfig.Certificates) > 0 {
75-
return TPM{}, fmt.Errorf("certificates value in ExtTLSConfig Ignored")
76-
}
77-
78-
if len(conf.ExtTLSConfig.CipherSuites) > 0 {
79-
return TPM{}, fmt.Errorf("cipherSuites value in ExtTLSConfig Ignored")
80-
}
81-
}
8272
return *conf, nil
8373
}
8474

@@ -237,18 +227,3 @@ func (t TPM) TLSCertificate() tls.Certificate {
237227
Certificate: [][]byte{t.x509Certificate.Raw},
238228
}
239229
}
240-
241-
func (t TPM) TLSConfig() *tls.Config {
242-
243-
return &tls.Config{
244-
Certificates: []tls.Certificate{t.TLSCertificate()},
245-
246-
RootCAs: t.ExtTLSConfig.RootCAs,
247-
ClientCAs: t.ExtTLSConfig.ClientCAs,
248-
ClientAuth: t.ExtTLSConfig.ClientAuth,
249-
ServerName: t.ExtTLSConfig.ServerName,
250-
CipherSuites: t.ExtTLSConfig.CipherSuites,
251-
MaxVersion: t.ExtTLSConfig.MaxVersion,
252-
MinVersion: t.ExtTLSConfig.MinVersion,
253-
}
254-
}

0 commit comments

Comments
 (0)