Imported Upstream version 4.4.0.182

Former-commit-id: ea38b2115ac3af9a394fe6cddf2be2acd11bc002
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-06-14 09:39:34 +00:00
parent ee13743634
commit 180e8b1935
125 changed files with 1658 additions and 521 deletions

View File

@ -40,65 +40,16 @@ namespace Mono.Security.Protocol.Tls
public static CipherSuiteCollection GetSupportedCiphers (bool server, SecurityProtocolType protocol)
{
CipherSuiteCollection suites;
switch (protocol) {
case SecurityProtocolType.Default:
case SecurityProtocolType.Tls:
suites = CipherSuiteFactory.GetTls1SupportedCiphers ();
break;
return CipherSuiteFactory.GetTls1SupportedCiphers ();
case SecurityProtocolType.Ssl3:
suites = CipherSuiteFactory.GetSsl3SupportedCiphers ();
break;
return CipherSuiteFactory.GetSsl3SupportedCiphers ();
case SecurityProtocolType.Ssl2:
default:
throw new NotSupportedException ("Unsupported security protocol type");
}
IEnumerable<string> list = null;
#if INSIDE_SYSTEM
// if SSL/TLS support is built-in System.dll (e.g. monotouch) then we can access ServicePointManager
// extension directly
var cb = server ? ServicePointManager.ServerCipherSuitesCallback : ServicePointManager.ClientCipherSuitesCallback;
if (cb == null)
return suites; // e.g. no callback was set
list = cb ((System.Net.SecurityProtocolType) (int) protocol, suites.GetNames ());
#elif !BOOTSTRAP_BASIC
// Mono.Security must work on MS.NET so it cannot depend on any Mono-specific extensions
PropertyInfo pi = null;
if (server) {
if (server_callback == null)
server_callback = spm.GetProperty ("ServerCipherSuitesCallback", BindingFlags.Static | BindingFlags.Public);
pi = server_callback;
} else {
if (client_callback == null)
client_callback = spm.GetProperty ("ClientCipherSuitesCallback", BindingFlags.Static | BindingFlags.Public);
pi = client_callback;
}
if (pi == null)
return suites; // e.g. MS runtime - return every supported suites
var cb = (Delegate) pi.GetGetMethod ().Invoke (null, null);
if (cb == null)
return suites; // e.g. no callback was set - return every supported suites
list = (IEnumerable<string>) cb.DynamicInvoke (new object[] {
(System.Net.SecurityProtocolType) (int) protocol, suites.GetNames ()
});
#else
// TODO: right now the callback is only available when using System.Net.* types for SSL/TLS
return suites;
#endif
CipherSuiteCollection allowed = new CipherSuiteCollection (protocol);
if (list != null) {
foreach (var name in list) {
// add any supported (ignore unknowns) ciphers requested by the callback
var cipher = suites [name];
if (cipher != null)
allowed.Add (cipher);
}
}
return allowed;
}
#region Private Static Methods