Skip to content

Commit b1a8eca

Browse files
committed
[unitytls] Making use of Settings.EnabledCiphers now
1 parent a47260d commit b1a8eca

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

mcs/class/System/Mono.UnityTls/UnityTlsContext.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,27 @@ protected override void Dispose (bool disposing)
218218

219219
public override void StartHandshake ()
220220
{
221-
// TODO: Check if we started a handshake already?
222-
// TODO, Not supported by UnityTls as of writing
221+
// TODO: Client->Server authentification is not supported by UnityTls as of writing
223222
if (IsServer && AskForClientCertificate) {
224223
throw new NotImplementedException ("No support for server-sided client certificate check yet.");
225224
}
226225

227-
// TODO: Set ciphers from Settings.EnabledCiphers
226+
if (Settings != null && Settings.EnabledCiphers != null) {
227+
var ciphers = new UnityTls.unitytls_ciphersuite [Settings.EnabledCiphers.Length];
228+
for (int i = 0; i < ciphers.Length; i++)
229+
ciphers [i] = (UnityTls.unitytls_ciphersuite)Settings.EnabledCiphers [i];
230+
231+
var errorState = unityTlsNative.unitytls_errorstate_create ();
232+
fixed (UnityTls.unitytls_ciphersuite* ciphersPtr = ciphers)
233+
unityTlsNative.unitytls_tlsctx_set_supported_ciphersuites (m_TlsContext, ciphersPtr, ciphers.Length, &errorState);
234+
Unity.Debug.CheckAndThrow (errorState, "Failed to set list of supported ciphers", AlertDescription.HandshakeFailure);
235+
}
228236
}
229237

230238
public override bool ProcessHandshake ()
231239
{
232-
var errorState = UnityTls.GetInterface().unitytls_errorstate_create ();
233-
var result = UnityTls.GetInterface().unitytls_tlsctx_process_handshake (m_TlsContext, &errorState);
240+
var errorState = unityTlsNative.unitytls_errorstate_create ();
241+
var result = unityTlsNative.unitytls_tlsctx_process_handshake (m_TlsContext, &errorState);
234242
if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK)
235243
return false;
236244

0 commit comments

Comments
 (0)