Messaging: Make tls version configurable
This commit is contained in:
@@ -20,10 +20,18 @@ Public Class MailSender
|
|||||||
SslPolicyErrors.RemoteCertificateChainErrors Or ' self-signed
|
SslPolicyErrors.RemoteCertificateChainErrors Or ' self-signed
|
||||||
SslPolicyErrors.RemoteCertificateNameMismatch ' name mismatch
|
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)
|
Public Sub New(pLogConfig As LogConfig)
|
||||||
MyBase.New(pLogConfig)
|
MyBase.New(pLogConfig)
|
||||||
End Sub
|
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>
|
''' <summary>
|
||||||
''' Start a connection with the specified server and return the SMTP client. Throws if there was an error.
|
''' Start a connection with the specified server and return the SMTP client. Throws if there was an error.
|
||||||
''' </summary>
|
''' </summary>
|
||||||
@@ -33,7 +41,7 @@ Public Class MailSender
|
|||||||
''' <param name="pPassword"></param>
|
''' <param name="pPassword"></param>
|
||||||
''' <param name="pAuthType"></param>
|
''' <param name="pAuthType"></param>
|
||||||
''' <returns></returns>
|
''' <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
|
Server = pServer
|
||||||
Port = pPort
|
Port = pPort
|
||||||
User = pUser
|
User = pUser
|
||||||
@@ -51,6 +59,11 @@ Public Class MailSender
|
|||||||
|
|
||||||
Logger.Debug("Initializing Connection with Auth type [{0}].", pAuthType)
|
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
|
If pAuthType = "SSL" Then
|
||||||
Try
|
Try
|
||||||
If pPort = 465 Then
|
If pPort = 465 Then
|
||||||
|
|||||||
Reference in New Issue
Block a user