Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:fasthttp server with tlsConfig #1595

Merged
merged 5 commits into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1677,14 +1677,13 @@ func (s *Server) ListenAndServeTLSEmbed(addr string, certData, keyData []byte) e
// the function will use previously added TLS configuration.
func (s *Server) ServeTLS(ln net.Listener, certFile, keyFile string) error {
s.mu.Lock()
err := s.AppendCert(certFile, keyFile)
if err != nil && err != errNoCertOrKeyProvided {
s.mu.Unlock()
return err
}
if s.TLSConfig == nil {
s.mu.Unlock()
return errNoCertOrKeyProvided
s.configTLS()
configHasCert := len(s.TLSConfig.Certificates) > 0 || s.TLSConfig.GetCertificate != nil
if !configHasCert || certFile != "" || keyFile != "" {
erikdubbelboer marked this conversation as resolved.
Show resolved Hide resolved
if err := s.AppendCert(certFile, keyFile); err != nil {
s.mu.Unlock()
return err
}
}

// BuildNameToCertificate has been deprecated since 1.14.
Expand All @@ -1706,15 +1705,13 @@ func (s *Server) ServeTLS(ln net.Listener, certFile, keyFile string) error {
// the function will use previously added TLS configuration.
func (s *Server) ServeTLSEmbed(ln net.Listener, certData, keyData []byte) error {
s.mu.Lock()

err := s.AppendCertEmbed(certData, keyData)
if err != nil && err != errNoCertOrKeyProvided {
s.mu.Unlock()
return err
}
if s.TLSConfig == nil {
s.mu.Unlock()
return errNoCertOrKeyProvided
s.configTLS()
configHasCert := len(s.TLSConfig.Certificates) > 0 || s.TLSConfig.GetCertificate != nil
if !configHasCert || len(certData) != 0 || len(keyData) != 0 {
if err := s.AppendCertEmbed(certData, keyData); err != nil {
s.mu.Unlock()
return err
}
}

// BuildNameToCertificate has been deprecated since 1.14.
Expand Down