diff --git a/source/implementations/f7/Meadow.F7/F7PlatformOS.cs b/source/implementations/f7/Meadow.F7/F7PlatformOS.cs
index 668d7bc83..ca6d80b9f 100644
--- a/source/implementations/f7/Meadow.F7/F7PlatformOS.cs
+++ b/source/implementations/f7/Meadow.F7/F7PlatformOS.cs
@@ -93,6 +93,16 @@ public int[] GetProcessorUtilization()
return new[] {100 - Core.Interop.Nuttx.meadow_idle_monitor_get_value()};
}
+
+ ///
+ /// Enum representing different server certificate validation error returns.
+ ///
+ public enum ServerCertificateValidationError
+ {
+ InvalidMode = -1,
+ CannotChangeAfterInitialization = -2
+ }
+
///
public void SetServerCertificateValidationMode(ServerCertificateValidationMode authmode)
{
@@ -107,12 +117,24 @@ public void SetServerCertificateValidationMode(ServerCertificateValidationMode a
}
int ret = Core.Interop.Nuttx.mono_mbedtls_set_server_cert_authmode(authModeInt);
- if (ret < 0)
+ if (ret == InvalidMode)
{
- string errorMessage = $"Error setting validation mode.";
+ string errorMessage = $"Invalid validation mode: {authModeInt}";
+ Resolver.Log.Error($"Invalid validation mode: {authModeInt}");
+ throw new ArgumentException(errorMessage);
+ }
+ else if (ret == CannotChangeAfterInitialization)
+ {
+ string errorMessage = $"The server certificate validation mode cannot be changed after the TLS initialization.";
Resolver.Log.Error(errorMessage);
throw new Exception(errorMessage);
}
+ else
+ {
+ string errorMessage = $"Error setting validation mode.";
+ Resolver.Log.Error(errorMessage);
+ throw new Exception(errorMessage);
+ }
Resolver.Log.Trace($"Server certificate validation mode set to {authmode} successfully!");