Skip to content

Commit a150d79

Browse files
committed
Further improvements for SSL/TLS authenticate (#411)
***NO_CI*** (cherry picked from commit e0b6dbc)
1 parent 8896bcc commit a150d79

2 files changed

Lines changed: 166 additions & 59 deletions

File tree

nanoFramework.System.Net/Security/SslError.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// See LICENSE file in the project root for full license information.
44
//
55

6+
using System.Security.Cryptography;
7+
68
namespace System.Net.Sockets
79
{
810

@@ -12,8 +14,8 @@ namespace System.Net.Sockets
1214
/// </summary>
1315
/// <remarks>
1416
/// Values are kept in sync with the <c>SSL_Error</c> enum in the native interpreter
15-
/// (<c>ssl_functions.h</c>). <see cref="System.Net.Security.SslStream"/> surfaces these
16-
/// through <see cref="System.Security.Cryptography.CryptographicException.ErrorCode"/>
17+
/// (<c>ssl_functions.h</c>). <see cref="Security.SslStream"/> surfaces these
18+
/// through <see cref="CryptographicException.ErrorCode"/>
1719
/// when SSL context setup fails.
1820
/// </remarks>
1921
///
@@ -75,5 +77,34 @@ public enum SslError : byte
7577
/// This is an internal mbedTLS error that should not occur under normal conditions.
7678
/// </summary>
7779
SetupFailed,
80+
81+
/// <summary>
82+
/// The SSL context was not valid when attempting the handshake.
83+
/// Thrown as <see cref="InvalidOperationException"/>.
84+
/// </summary>
85+
HandshakeBadContext,
86+
87+
/// <summary>
88+
/// Setting the server hostname for SNI failed during the handshake.
89+
/// Thrown as <see cref="InvalidOperationException"/>.
90+
/// </summary>
91+
HandshakeSetHostname,
92+
93+
/// <summary>
94+
/// Certificate verification failed during the handshake.
95+
/// Thrown as <see cref="CryptographicException"/>
96+
/// with <see cref="CryptographicException.ErrorCode"/>
97+
/// set to the bitmask of <c>MBEDTLS_X509_BADCERT_*</c> verification flags returned
98+
/// by <c>mbedtls_ssl_get_verify_result()</c>.
99+
/// </summary>
100+
HandshakeCertVerifyFailed,
101+
102+
/// <summary>
103+
/// The TLS handshake failed.
104+
/// Thrown as <see cref="CryptographicException"/>
105+
/// with <see cref="CryptographicException.ErrorCode"/>
106+
/// set to the raw negative mbedTLS error code.
107+
/// </summary>
108+
HandshakeFailed,
78109
}
79110
}

0 commit comments

Comments
 (0)