[btls] rewrite mono_btls_ssl_ctx_set_ciphers (#8849)
commit27c4f785e20c31d226cbcbe534925bb3c329481b
authorDavid Benjamin <davidben@davidben.net>
Thu, 24 May 2018 16:33:19 +0000 (24 12:33 -0400)
committerMartin Baulig <mabaul@microsoft.com>
Thu, 24 May 2018 16:33:19 +0000 (24 12:33 -0400)
tree483f230b45e63943ca95c689a4597e0cff80b567
parent435ea75843743ad3775ab6f5aac158ee7d8e5812
[btls] rewrite mono_btls_ssl_ctx_set_ciphers (#8849)

Rather than reaching into the library internals and potentially
violating its invariants, assemble a cipher string and call the
supported public API. (There's no need to touch the version-specific
cipher lists because mono/btls never configures them.) The existing code
also had a bug; it incorrectly assumed OPENSSL_malloc returned a
zero-initialized buffer for in_group_flags. (Though Mono doesn't set
SSL_OP_CIPHER_SERVER_PREFERENCE, so I suspect this was a no-op.)

Additionally, this should hopefully ease updating to a less outdated
version of BoringSSL in the future.

Note I've changed the return value of this function from returning the
number of ciphers to merely returning 0/1 for whether the operation
succeeded. The only caller of this function, MonoBtlsSslCtx.SetCiphers,
only cares about success vs. failure.
mono/btls/btls-ssl-ctx.c