Messaging: Make tls version configurable
This commit is contained in:
parent
27e3462b6e
commit
8738fd8300
@ -20,10 +20,18 @@ Public Class MailSender
|
||||
SslPolicyErrors.RemoteCertificateChainErrors Or ' self-signed
|
||||
SslPolicyErrors.RemoteCertificateNameMismatch ' name mismatch
|
||||
|
||||
Public Class MailSenderOptions
|
||||
Public Property TlsVersion As Security.Authentication.SslProtocols = Security.Authentication.SslProtocols.Default
|
||||
End Class
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function ConnectToServer(pServer As String, pPort As Integer, pUser As String, pPassword As String, pAuthType As String) As Boolean
|
||||
Return ConnectToServer(pServer, pPort, pUser, pPassword, pAuthType)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Start a connection with the specified server and return the SMTP client. Throws if there was an error.
|
||||
''' </summary>
|
||||
@ -33,7 +41,7 @@ Public Class MailSender
|
||||
''' <param name="pPassword"></param>
|
||||
''' <param name="pAuthType"></param>
|
||||
''' <returns></returns>
|
||||
Public Function ConnectToServer(pServer As String, pPort As Integer, pUser As String, pPassword As String, pAuthType As String) As Boolean
|
||||
Public Function ConnectToServer(pServer As String, pPort As Integer, pUser As String, pPassword As String, pAuthType As String, pOptions As MailSenderOptions) As Boolean
|
||||
Server = pServer
|
||||
Port = pPort
|
||||
User = pUser
|
||||
@ -51,6 +59,11 @@ Public Class MailSender
|
||||
|
||||
Logger.Debug("Initializing Connection with Auth type [{0}].", pAuthType)
|
||||
|
||||
' Set TLS Version manually if requested
|
||||
If pOptions.TlsVersion <> Security.Authentication.SslProtocols.Default Then
|
||||
oSession.SSLConfiguration.EnabledSslProtocols = pOptions.TlsVersion
|
||||
End If
|
||||
|
||||
If pAuthType = "SSL" Then
|
||||
Try
|
||||
If pPort = 465 Then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user