Skip to content

Commit dbd24a9

Browse files
authored
[advancedTLS] Removed deprecated APIs in advancedTLS (#7303)
* remove deprecated APIs from advancedTLS
1 parent 30c0cdd commit dbd24a9

File tree

9 files changed

+31
-675
lines changed

9 files changed

+31
-675
lines changed

security/advancedtls/advancedtls.go

Lines changed: 0 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,19 @@ type HandshakeVerificationInfo struct {
6262
Leaf *x509.Certificate
6363
}
6464

65-
// VerificationFuncParams contains parameters available to users when
66-
// implementing CustomVerificationFunc.
67-
// The fields in this struct are read-only.
68-
//
69-
// Deprecated: use HandshakeVerificationInfo instead.
70-
type VerificationFuncParams = HandshakeVerificationInfo
71-
7265
// PostHandshakeVerificationResults contains the information about results of
7366
// PostHandshakeVerificationFunc.
7467
// PostHandshakeVerificationResults is an empty struct for now. It may be extended in the
7568
// future to include more information.
7669
type PostHandshakeVerificationResults struct{}
7770

78-
// VerificationResults contains the information about results of
79-
// PostHandshakeVerificationFunc.
80-
// Deprecated: use PostHandshakeVerificationResults instead.
81-
type VerificationResults = PostHandshakeVerificationResults
82-
8371
// PostHandshakeVerificationFunc is the function defined by users to perform
8472
// custom verification checks after chain building and regular handshake
8573
// verification has been completed.
8674
// PostHandshakeVerificationFunc should return (nil, error) if the authorization
8775
// should fail, with the error containing information on why it failed.
8876
type PostHandshakeVerificationFunc func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error)
8977

90-
// CustomVerificationFunc is the function defined by users to perform custom
91-
// verification check.
92-
// CustomVerificationFunc returns nil if the authorization fails; otherwise
93-
// returns an empty struct.
94-
//
95-
// Deprecated: use PostHandshakeVerificationFunc instead.
96-
type CustomVerificationFunc = PostHandshakeVerificationFunc
97-
9878
// ConnectionInfo contains the parameters available to users when
9979
// implementing GetRootCertificates.
10080
type ConnectionInfo struct {
@@ -104,12 +84,6 @@ type ConnectionInfo struct {
10484
RawCerts [][]byte
10585
}
10686

107-
// GetRootCAsParams contains the parameters available to users when
108-
// implementing GetRootCAs.
109-
//
110-
// Deprecated: use ConnectionInfo instead.
111-
type GetRootCAsParams = ConnectionInfo
112-
11387
// RootCertificates is the result of GetRootCertificates.
11488
// If users want to reload the root trust certificate, it is required to return
11589
// the proper TrustCerts in GetRootCAs.
@@ -118,13 +92,6 @@ type RootCertificates struct {
11892
TrustCerts *x509.CertPool
11993
}
12094

121-
// GetRootCAsResults contains the results of GetRootCAs.
122-
// If users want to reload the root trust certificate, it is required to return
123-
// the proper TrustCerts in GetRootCAs.
124-
//
125-
// Deprecated: use RootCertificates instead.
126-
type GetRootCAsResults = RootCertificates
127-
12895
// RootCertificateOptions contains options to obtain root trust certificates
12996
// for both the client and the server.
13097
// At most one field should be set. If none of them are set, we use the system
@@ -134,11 +101,6 @@ type RootCertificateOptions struct {
134101
// If RootCertificates is set, it will be used every time when verifying
135102
// the peer certificates, without performing root certificate reloading.
136103
RootCertificates *x509.CertPool
137-
// If RootCACerts is set, it will be used every time when verifying
138-
// the peer certificates, without performing root certificate reloading.
139-
//
140-
// Deprecated: use RootCertificates instead.
141-
RootCACerts *x509.CertPool
142104
// If GetRootCertificates is set, it will be invoked to obtain root certs for
143105
// every new connection.
144106
GetRootCertificates func(params *ConnectionInfo) (*RootCertificates, error)
@@ -213,14 +175,6 @@ const (
213175
SkipVerification
214176
)
215177

216-
// ClientOptions contains the fields needed to be filled by the client.
217-
// Deprecated: use Options instead.
218-
type ClientOptions = Options
219-
220-
// ServerOptions contains the fields needed to be filled by the server.
221-
// Deprecated: use Options instead.
222-
type ServerOptions = Options
223-
224178
// Options contains the fields a user can configure when setting up TLS clients
225179
// and servers
226180
type Options struct {
@@ -233,13 +187,6 @@ type Options struct {
233187
// If this is set, we will perform this customized check after doing the
234188
// normal check(s) indicated by setting VerificationType.
235189
AdditionalPeerVerification PostHandshakeVerificationFunc
236-
// VerifyPeer is a custom verification check after certificate signature
237-
// check.
238-
// If this is set, we will perform this customized check after doing the
239-
// normal check(s) indicated by setting VerificationType.
240-
//
241-
// Deprecated: use AdditionalPeerVerification instead.
242-
VerifyPeer PostHandshakeVerificationFunc
243190
// RootOptions is OPTIONAL on server side. This field only needs to be set if
244191
// mutual authentication is required(RequireClientCert is true).
245192
RootOptions RootCertificateOptions
@@ -251,26 +198,9 @@ type Options struct {
251198
// the `VerificationType` enum for the different options.
252199
// Default: CertAndHostVerification
253200
VerificationType VerificationType
254-
// VType is the verification type on the server side.
255-
//
256-
// Deprecated: use VerificationType instead.
257-
VType VerificationType
258201
// RevocationOptions is the configurations for certificate revocation checks.
259202
// It could be nil if such checks are not needed.
260203
RevocationOptions *RevocationOptions
261-
// RevocationConfig is the configurations for certificate revocation checks.
262-
// It could be nil if such checks are not needed.
263-
//
264-
// Deprecated: use RevocationOptions instead.
265-
RevocationConfig *RevocationConfig
266-
// MinVersion contains the minimum TLS version that is acceptable.
267-
//
268-
// Deprecated: use MinTLSVersion instead.
269-
MinVersion uint16
270-
// MaxVersion contains the maximum TLS version that is acceptable.
271-
//
272-
// Deprecated: use MaxTLSVersion instead.
273-
MaxVersion uint16
274204
// MinTLSVersion contains the minimum TLS version that is acceptable.
275205
// The value should be set using tls.VersionTLSxx from https://pkg.go.dev/crypto/tls
276206
// By default, TLS 1.2 is currently used as the minimum when acting as a
@@ -296,35 +226,6 @@ type Options struct {
296226
}
297227

298228
func (o *Options) clientConfig() (*tls.Config, error) {
299-
// TODO(gtcooke94) Remove this block when o.VerifyPeer is remoed.
300-
// VerifyPeer is deprecated, but do this to aid the transitory migration time.
301-
if o.AdditionalPeerVerification == nil {
302-
o.AdditionalPeerVerification = o.VerifyPeer
303-
}
304-
// TODO(gtcooke94). VType is deprecated, eventually remove this block. This
305-
// will ensure that users still explicitly setting `VType` will get the
306-
// setting to the right place.
307-
if o.VType != CertAndHostVerification {
308-
o.VerificationType = o.VType
309-
}
310-
// TODO(gtcooke94) MinVersion and MaxVersion are deprected, eventually
311-
// remove this block. This is a temporary fallback to ensure that if the
312-
// refactored names aren't set we use the old names.
313-
if o.MinTLSVersion == 0 {
314-
o.MinTLSVersion = o.MinVersion
315-
}
316-
if o.MaxTLSVersion == 0 {
317-
o.MaxTLSVersion = o.MaxVersion
318-
}
319-
// TODO(gtcooke94) RootCACerts is deprecated, eventually remove this block.
320-
// This will ensure that users still explicitly setting RootCACerts will get
321-
// the setting int the right place.
322-
if o.RootOptions.RootCACerts != nil {
323-
o.RootOptions.RootCertificates = o.RootOptions.RootCACerts
324-
// There are additional checks that only 1 field of `RootOptions` is
325-
// non-nil, so set the deprecated field to nil
326-
o.RootOptions.RootCACerts = nil
327-
}
328229
if o.VerificationType == SkipVerification && o.AdditionalPeerVerification == nil {
329230
return nil, fmt.Errorf("client needs to provide custom verification mechanism if choose to skip default verification")
330231
}
@@ -410,35 +311,6 @@ func (o *Options) clientConfig() (*tls.Config, error) {
410311
}
411312

412313
func (o *Options) serverConfig() (*tls.Config, error) {
413-
// TODO(gtcooke94) Remove this block when o.VerifyPeer is remoed.
414-
// VerifyPeer is deprecated, but do this to aid the transitory migration time.
415-
if o.AdditionalPeerVerification == nil {
416-
o.AdditionalPeerVerification = o.VerifyPeer
417-
}
418-
// TODO(gtcooke94). VType is deprecated, eventually remove this block. This
419-
// will ensure that users still explicitly setting `VType` will get the
420-
// setting to the right place.
421-
if o.VType != CertAndHostVerification {
422-
o.VerificationType = o.VType
423-
}
424-
// TODO(gtcooke94) MinVersion and MaxVersion are deprected, eventually
425-
// remove this block. This is a temporary fallback to ensure that if the
426-
// refactored names aren't set we use the old names.
427-
if o.MinTLSVersion == 0 {
428-
o.MinTLSVersion = o.MinVersion
429-
}
430-
if o.MaxTLSVersion == 0 {
431-
o.MaxTLSVersion = o.MaxVersion
432-
}
433-
// TODO(gtcooke94) RootCACerts is deprecated, eventually remove this block.
434-
// This will ensure that users still explicitly setting RootCACerts will get
435-
// the setting int the right place.
436-
if o.RootOptions.RootCACerts != nil {
437-
o.RootOptions.RootCertificates = o.RootOptions.RootCACerts
438-
// There are additional checks that only 1 field of `RootOptions` is
439-
// non-nil, so set the deprecated field to nil
440-
o.RootOptions.RootCACerts = nil
441-
}
442314
if o.RequireClientCert && o.VerificationType == SkipVerification && o.AdditionalPeerVerification == nil {
443315
return nil, fmt.Errorf("server needs to provide custom verification mechanism if choose to skip default verification, but require client certificate(s)")
444316
}
@@ -728,12 +600,6 @@ func buildVerifyFunc(c *advancedTLSCreds,
728600
// NewClientCreds uses ClientOptions to construct a TransportCredentials based
729601
// on TLS.
730602
func NewClientCreds(o *Options) (credentials.TransportCredentials, error) {
731-
// TODO(gtcooke94) RevocationConfig is deprecated, eventually remove this block.
732-
// This will ensure that users still explicitly setting RevocationConfig will get
733-
// the setting in the right place.
734-
if o.RevocationConfig != nil {
735-
o.RevocationOptions = o.RevocationConfig
736-
}
737603
conf, err := o.clientConfig()
738604
if err != nil {
739605
return nil, err
@@ -753,12 +619,6 @@ func NewClientCreds(o *Options) (credentials.TransportCredentials, error) {
753619
// NewServerCreds uses ServerOptions to construct a TransportCredentials based
754620
// on TLS.
755621
func NewServerCreds(o *Options) (credentials.TransportCredentials, error) {
756-
// TODO(gtcooke94) RevocationConfig is deprecated, eventually remove this block.
757-
// This will ensure that users still explicitly setting RevocationConfig will get
758-
// the setting in the right place.
759-
if o.RevocationConfig != nil {
760-
o.RevocationOptions = o.RevocationConfig
761-
}
762622
conf, err := o.serverConfig()
763623
if err != nil {
764624
return nil, err

0 commit comments

Comments
 (0)