Skip to content
Closed
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
9 changes: 6 additions & 3 deletions xmpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,11 @@ func (c *Client) init(o *Options) error {
}

// If the server requires STARTTLS, attempt to do so.
if f, err = c.startTLSIfRequired(f, o, domain); err != nil {
return err
// unless the client has specified NoTLS
if !o.NoTLS {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we should use the directTLS setting to control whether StartTLS is used. I'll check if there is an alternative.

if f, err = c.startTLSIfRequired(f, o, domain); err != nil {
return err
}
}
var mechanism, channelBinding, clientFirstMessage, clientFinalMessageBare, authMessage string
var bind2Data, resource, userAgentSW, userAgentDev, userAgentID, fastAuth, saslUpgrade string
Expand Down Expand Up @@ -664,7 +667,7 @@ func (c *Client) init(o *Options) error {
case slices.Contains(mechSlice, "X-OAUTH2"):
mechanism = "X-OAUTH2"
// Do not use PLAIN auth if NoPlain is set.
case slices.Contains(mechSlice, "PLAIN") && tlsConnOK && !o.NoPLAIN:
case slices.Contains(mechSlice, "PLAIN") && (tlsConnOK || o.NoTLS) && !o.NoPLAIN:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think from a security point of view we should make it very hard to use PLAIN auth over an unencrypted connection. So maybe better not allow PLAIN here, but set set Mechanism in Options to PLAIN, then the else clause won't be used.

mechanism = "PLAIN"
}
}
Expand Down