Skip to content

Commit

Permalink
Only re-EHLO if a SASL mechanism has negotiated a security layer
Browse files Browse the repository at this point in the history
Fixes issue #162
  • Loading branch information
jstedfast committed Apr 10, 2017
1 parent 67b8e45 commit d2de216
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 2 additions & 3 deletions MailKit/Net/Smtp/SmtpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ enum SmtpCommand {
/// </example>
public SmtpClient () : this (new NullProtocolLogger ())
{
QueryCapabilitiesAfterAuthenticating = true;
}

/// <summary>
Expand All @@ -126,7 +125,6 @@ public SmtpClient () : this (new NullProtocolLogger ())
/// </example>
public SmtpClient (IProtocolLogger protocolLogger) : base (protocolLogger)
{
QueryCapabilitiesAfterAuthenticating = true;
}

/// <summary>
Expand All @@ -140,6 +138,7 @@ public SmtpClient (IProtocolLogger protocolLogger) : base (protocolLogger)
/// the capabilities after successfully authenticating, the default is <c>true</c>.</para>
/// </remarks>
/// <value><c>true</c> if the capabilities should be re-queried after authenticating; otherwise, <c>false</c>.</value>
[Obsolete ("This property is no longer needed.")]
public bool QueryCapabilitiesAfterAuthenticating {
get; set;
}
Expand Down Expand Up @@ -654,7 +653,7 @@ void Ehlo (CancellationToken cancellationToken)
}

if (response.StatusCode == SmtpStatusCode.AuthenticationSuccessful) {
if (QueryCapabilitiesAfterAuthenticating)
if (sasl.NegotiatedSecurityLayer)
Ehlo (cancellationToken);
authenticated = true;
OnAuthenticated (response.Response);
Expand Down
13 changes: 13 additions & 0 deletions MailKit/Security/SaslMechanism.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ public bool IsAuthenticated {
get; protected set;
}

/// <summary>
/// Gets whether or not a security layer was negotiated.
/// </summary>
/// <remarks>
/// <para>Gets whether or not a security layer has been negotiated by the SASL mechanism.</para>
/// <note type="note">Some SASL mechanisms, such as GSSAPI, are able to negotiate security layers
/// such as integrity and confidentiality protection.</note>
/// </remarks>
/// <value><c>true</c> if a security layer was negotiated; otherwise, <c>false</c>.</value>
public virtual bool NegotiatedSecurityLayer {
get { return false; }
}

/// <summary>
/// Gets or sets the URI of the service.
/// </summary>
Expand Down

0 comments on commit d2de216

Please sign in to comment.