Skip to content

Commit

Permalink
Improve handling of SslProtocols (#3)
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
networkfusion authored and josesimoes committed Jul 15, 2019
1 parent d197215 commit 0d92251
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions M2Mqtt/Net/MqttNetworkChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,15 +467,17 @@ public static AddressFamily GetAddressFamily(this IPAddress ipAddress)
/// </summary>
public static class MqttSslUtility
{
#if (!MF_FRAMEWORK_VERSION_V4_2 && !MF_FRAMEWORK_VERSION_V4_3 && !COMPACT_FRAMEWORK && !NANOFRAMEWORK_1_0)
#if (!MF_FRAMEWORK_VERSION_V4_2 && !MF_FRAMEWORK_VERSION_V4_3 && !COMPACT_FRAMEWORK)
public static SslProtocols ToSslPlatformEnum(MqttSslProtocols mqttSslProtocol)
{
switch (mqttSslProtocol)
{
case MqttSslProtocols.None:
return SslProtocols.None;
#if !(NANOFRAMEWORK_1_0)
case MqttSslProtocols.SSLv3:
return SslProtocols.Ssl3;
#endif
case MqttSslProtocols.TLSv1_0:
return SslProtocols.Tls;
case MqttSslProtocols.TLSv1_1:
Expand All @@ -486,7 +488,7 @@ public static SslProtocols ToSslPlatformEnum(MqttSslProtocols mqttSslProtocol)
throw new ArgumentException("SSL/TLS protocol version not supported");
}
}
#elif (MF_FRAMEWORK_VERSION_V4_2 || MF_FRAMEWORK_VERSION_V4_3 || NANOFRAMEWORK_1_0)
#elif (MF_FRAMEWORK_VERSION_V4_2 || MF_FRAMEWORK_VERSION_V4_3)
public static SslProtocols ToSslPlatformEnum(MqttSslProtocols mqttSslProtocol)
{
switch (mqttSslProtocol)
Expand All @@ -495,20 +497,12 @@ public static SslProtocols ToSslPlatformEnum(MqttSslProtocols mqttSslProtocol)
return SslProtocols.None;
case MqttSslProtocols.TLSv1_0:
return SslProtocols.Tls;
#if (NANOFRAMEWORK_1_0)
case MqttSslProtocols.TLSv1_1:
return SslProtocols.Tls11;
case MqttSslProtocols.TLSv1_2:
return SslProtocols.Tls12;
case MqttSslProtocols.SSLv3:
#else
case MqttSslProtocols.TLSv1_1:
case MqttSslProtocols.TLSv1_2:
#endif
default:
throw new ArgumentException("SSL/TLS protocol version not supported");
}
}
#endif
}
}
}
}

0 comments on commit 0d92251

Please sign in to comment.