提交 ac277b39 编写于 作者: J Jonathan Pryor

Add preliminary HTTPS handling support for Android.

The problem is that Android only exposes Java APIs for ~everything of
consequence, including/especially X509 Certificate validation.  Since
we want Mono-based HTTPS support to use the underlying platform
certificates, this requires some amount of Java-using glue.  However,
we don't want to pull in a ton of Java glue into System.dll (bleh!),
so we'll instead place the glue into Mono.Android.dll's
Android.Runtime.AndroidEnvironment.TrustEvaluateSsl(), and instead
create a delegate which will invoke TrustEvaluateSsl() when needed.
上级 936c28ad
......@@ -402,8 +402,19 @@ namespace System.Net
static bool is_macosx = System.IO.File.Exists (MSX.OSX509Certificates.SecurityLibrary);
static X509RevocationMode revocation_mode;
#if MONODROID
static readonly Converter<Mono.Security.X509.X509CertificateCollection, bool> monodroidCallback;
#endif
static ChainValidationHelper ()
{
#if MONODROID
monodroidCallback = (Converter<Mono.Security.X509.X509CertificateCollection, bool>)
Delegate.CreateDelegate (typeof(Converter<Mono.Security.X509.X509CertificateCollection, bool>),
Type.GetType ("Android.Runtime.AndroidEnvironment, Mono.Android", true)
.GetMethod ("TrustEvaluateSsl",
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic));
#endif
revocation_mode = X509RevocationMode.NoCheck;
try {
string str = Environment.GetEnvironmentVariable ("MONO_X509_REVOCATION_MODE");
......@@ -498,6 +509,14 @@ namespace System.Net
}
#endif
#if MONODROID
result = monodroidCallback (certs);
if (result) {
status11 = 0;
errors = 0;
}
#endif
if (policy != null && (!(policy is DefaultCertificatePolicy) || cb == null)) {
ServicePoint sp = null;
HttpWebRequest req = sender as HttpWebRequest;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册