1
0

web_mtls.go 576 B

12345678910111213141516171819
  1. package web
  2. import (
  3. "crypto/tls"
  4. "crypto/x509"
  5. )
  6. // applyNodeMtls configures the panel listener to request and verify client
  7. // certificates against pool. It uses VerifyClientCertIfGiven so browsers (which
  8. // present no client cert) keep working; a presented cert that fails to verify
  9. // aborts the handshake. With a nil pool the config is left untouched, so the
  10. // no-mTLS listener is byte-identical to before.
  11. func applyNodeMtls(cfg *tls.Config, pool *x509.CertPool) {
  12. if pool == nil {
  13. return
  14. }
  15. cfg.ClientAuth = tls.VerifyClientCertIfGiven
  16. cfg.ClientCAs = pool
  17. }