mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-23 02:50:39 +01:00
Improve error handling in SCRAM-SHA-X-PLUS authentication
Refactor error return to include more specific information and add a check for TLS connection state in SCRAM-SHA-X-PLUS authentication flow. This ensures clearer error messages and verifies essential prerequisites for secure authentication.
This commit is contained in:
parent
580981b158
commit
e4dd62475a
1 changed files with 4 additions and 1 deletions
|
@ -112,7 +112,7 @@ func (a *scramAuth) Next(fromServer []byte, more bool) ([]byte, error) {
|
|||
return resp, nil
|
||||
default:
|
||||
a.reset()
|
||||
return nil, errors.New("unexpected server response")
|
||||
return nil, fmt.Errorf("%w: %s", ErrUnexpectedServerResponse, string(fromServer))
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
|
@ -147,6 +147,9 @@ func (a *scramAuth) initialClientMessage() ([]byte, error) {
|
|||
|
||||
// SCRAM-SHA-X-PLUS auth requires channel binding
|
||||
if a.isPlus {
|
||||
if a.tlsConnState == nil {
|
||||
return nil, errors.New("tls connection state is required for SCRAM-SHA-X-PLUS")
|
||||
}
|
||||
bindType := "tls-unique"
|
||||
connState := a.tlsConnState
|
||||
bindData := connState.TLSUnique
|
||||
|
|
Loading…
Reference in a new issue