@@ -84,14 +84,15 @@ func (l listener) Accept() (net.Conn, error) {
8484
8585// Params wraps the parameters required to create an https communicator.
8686type Params struct {
87- Listener net.Listener // Where to listen for connections, required.
88- Cert , Key []byte // x509 encoded certificate and matching private key, required.
89- Streaming bool // Whether to enable streaming communications.
90- FrontendConfig * cpb.FrontendConfig // Configure how the frontend identifies and communicates with clients
91- StreamingLifespan time.Duration // Maximum time to keep a streaming connection open, defaults to 10 min.
92- StreamingCloseTime time.Duration // How much of StreamingLifespan to allocate to an orderly stream close, defaults to 30 sec.
93- StreamingJitter time.Duration // Maximum amount of jitter to add to StreamingLifespan.
94- MaxPerClientBatchProcessors uint32 // Maximum number of concurrent processors for messages coming from a single client.
87+ Listener net.Listener // Where to listen for connections, required.
88+ Cert , Key []byte // x509 encoded certificate and matching private key, required.
89+ GetCertificate func (* tls.ClientHelloInfo ) (* tls.Certificate , error ) // If set, used instead of Cert and Key.
90+ Streaming bool // Whether to enable streaming communications.
91+ FrontendConfig * cpb.FrontendConfig // Configure how the frontend identifies and communicates with clients
92+ StreamingLifespan time.Duration // Maximum time to keep a streaming connection open, defaults to 10 min.
93+ StreamingCloseTime time.Duration // How much of StreamingLifespan to allocate to an orderly stream close, defaults to 30 sec.
94+ StreamingJitter time.Duration // Maximum amount of jitter to add to StreamingLifespan.
95+ MaxPerClientBatchProcessors uint32 // Maximum number of concurrent processors for messages coming from a single client.
9596}
9697
9798// NewCommunicator creates a Communicator, which listens through l and identifies
@@ -123,13 +124,22 @@ func NewCommunicator(p Params) (*Communicator, error) {
123124 if p .FrontendConfig .GetCleartextHeaderConfig () == nil &&
124125 p .FrontendConfig .GetCleartextHeaderChecksumConfig () == nil &&
125126 p .FrontendConfig .GetCleartextXfccConfig () == nil {
126- c , err := tls .X509KeyPair (p .Cert , p .Key )
127- if err != nil {
128- return nil , err
127+
128+ getCertificate := p .GetCertificate
129+ if getCertificate == nil {
130+ c , err := tls .X509KeyPair (p .Cert , p .Key )
131+ if err != nil {
132+ return nil , err
133+ }
134+
135+ getCertificate = func (_ * tls.ClientHelloInfo ) (* tls.Certificate , error ) {
136+ return & c , nil
137+ }
129138 }
139+
130140 h .hs .TLSConfig = & tls.Config {
131- ClientAuth : tls .RequestClientCert ,
132- Certificates : []tls. Certificate { c } ,
141+ ClientAuth : tls .RequestClientCert ,
142+ GetCertificate : getCertificate ,
133143 CipherSuites : []uint16 {
134144 // We may as well allow only the strongest (as far as we can guess)
135145 // ciphers. Note that TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 is
0 commit comments