You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.459
Former-commit-id: 2a5b9df2014f72665850c7f885e7aed54704a53a
This commit is contained in:
parent
a355c1b831
commit
e5cd25ff4f
@@ -74,7 +74,6 @@ using System.Runtime.InteropServices;
|
||||
[assembly: StringFreezing]
|
||||
[assembly: DefaultDependency (LoadHint.Always)]
|
||||
|
||||
[assembly: InternalsVisibleTo ("btls-cert-sync, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
[assembly: InternalsVisibleTo ("Mono.Btls.Interface, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
[assembly: InternalsVisibleTo ("Mono.Security, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
|
||||
|
@@ -48,6 +48,10 @@ namespace Mono.Btls
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static IntPtr mono_btls_key_new ();
|
||||
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static void mono_btls_key_free (IntPtr handle);
|
||||
|
||||
@@ -63,6 +67,9 @@ namespace Mono.Btls
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static int mono_btls_key_is_rsa (IntPtr handle);
|
||||
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static int mono_btls_key_assign_rsa_private_key (IntPtr handle, byte[] der, int der_length);
|
||||
|
||||
new internal BoringKeyHandle Handle {
|
||||
get { return (BoringKeyHandle)base.Handle; }
|
||||
}
|
||||
@@ -99,6 +106,18 @@ namespace Mono.Btls
|
||||
CheckError (copy != IntPtr.Zero);
|
||||
return new MonoBtlsKey (new BoringKeyHandle (copy));
|
||||
}
|
||||
|
||||
public static MonoBtlsKey CreateFromRSAPrivateKey (System.Security.Cryptography.RSA privateKey)
|
||||
{
|
||||
var keyData = Mono.Security.Cryptography.PKCS8.PrivateKeyInfo.Encode (privateKey);
|
||||
var key = new MonoBtlsKey (new BoringKeyHandle (mono_btls_key_new ()));
|
||||
|
||||
var ret = mono_btls_key_assign_rsa_private_key (key.Handle.DangerousGetHandle (), keyData, keyData.Length);
|
||||
if (ret == 0)
|
||||
throw new MonoBtlsException ("Assigning private key failed.");
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -218,12 +218,10 @@ namespace Mono.Btls
|
||||
|
||||
public static string GetSystemStoreLocation ()
|
||||
{
|
||||
#if ANDROID
|
||||
#if MONODROID
|
||||
return "/system/etc/security/cacerts";
|
||||
#else
|
||||
var appData = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
|
||||
var path = Path.Combine (appData, ".mono", "certs", "NewTrust");
|
||||
return path;
|
||||
return MonoBtlsX509StoreManager.GetStorePath (MonoBtlsX509StoreType.MachineTrustedRoots);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -45,7 +45,7 @@ namespace Mono.Btls
|
||||
static class MonoBtlsX509StoreManager
|
||||
{
|
||||
static bool initialized;
|
||||
#if !ANDROID
|
||||
#if !MONODROID
|
||||
static string machineTrustedRootPath;
|
||||
static string machineIntermediateCAPath;
|
||||
static string machineUntrustedPath;
|
||||
@@ -70,7 +70,7 @@ namespace Mono.Btls
|
||||
|
||||
static void DoInitialize ()
|
||||
{
|
||||
#if !ANDROID
|
||||
#if !MONODROID
|
||||
var userPath = MX.X509StoreManager.NewCurrentUserPath;
|
||||
userTrustedRootPath = Path.Combine (userPath, MX.X509Stores.Names.TrustedRoot);
|
||||
userIntermediateCAPath = Path.Combine (userPath, MX.X509Stores.Names.IntermediateCA);
|
||||
@@ -85,7 +85,7 @@ namespace Mono.Btls
|
||||
|
||||
public static bool HasStore (MonoBtlsX509StoreType type)
|
||||
{
|
||||
#if ANDROID
|
||||
#if MONODROID
|
||||
return false;
|
||||
#else
|
||||
var path = GetStorePath (type);
|
||||
@@ -95,7 +95,7 @@ namespace Mono.Btls
|
||||
|
||||
public static string GetStorePath (MonoBtlsX509StoreType type)
|
||||
{
|
||||
#if ANDROID
|
||||
#if MONODROID
|
||||
throw new NotSupportedException ();
|
||||
#else
|
||||
Initialize ();
|
||||
|
@@ -47,7 +47,7 @@ namespace Mono.Btls
|
||||
class X509CertificateImplBtls : X509Certificate2Impl
|
||||
{
|
||||
MonoBtlsX509 x509;
|
||||
MonoBtlsKey privateKey;
|
||||
MonoBtlsKey nativePrivateKey;
|
||||
X500DistinguishedName subjectName;
|
||||
X500DistinguishedName issuerName;
|
||||
X509CertificateImplCollection intermediateCerts;
|
||||
@@ -70,7 +70,8 @@ namespace Mono.Btls
|
||||
{
|
||||
disallowFallback = other.disallowFallback;
|
||||
x509 = other.x509 != null ? other.x509.Copy () : null;
|
||||
privateKey = other.privateKey != null ? other.privateKey.Copy () : null;
|
||||
nativePrivateKey = other.nativePrivateKey != null ? other.nativePrivateKey.Copy () : null;
|
||||
fallback = other.fallback != null ? (X509Certificate2Impl)other.fallback.Clone () : null;
|
||||
if (other.intermediateCerts != null)
|
||||
intermediateCerts = other.intermediateCerts.Clone ();
|
||||
}
|
||||
@@ -104,7 +105,13 @@ namespace Mono.Btls
|
||||
internal MonoBtlsKey NativePrivateKey {
|
||||
get {
|
||||
ThrowIfContextInvalid ();
|
||||
return privateKey;
|
||||
if (nativePrivateKey == null && FallbackImpl.HasPrivateKey) {
|
||||
var key = FallbackImpl.PrivateKey as RSA;
|
||||
if (key == null)
|
||||
throw new NotSupportedException ("Currently only supports RSA private keys.");
|
||||
nativePrivateKey = MonoBtlsKey.CreateFromRSAPrivateKey (key);
|
||||
}
|
||||
return nativePrivateKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +277,7 @@ namespace Mono.Btls
|
||||
}
|
||||
|
||||
public override bool HasPrivateKey {
|
||||
get { return privateKey != null; }
|
||||
get { return nativePrivateKey != null || FallbackImpl.HasPrivateKey; }
|
||||
}
|
||||
|
||||
public override X500DistinguishedName IssuerName {
|
||||
@@ -290,12 +297,15 @@ namespace Mono.Btls
|
||||
|
||||
public override AsymmetricAlgorithm PrivateKey {
|
||||
get {
|
||||
if (privateKey == null || !privateKey.IsRsa)
|
||||
return null;
|
||||
var bytes = privateKey.GetBytes (true);
|
||||
if (nativePrivateKey == null || !nativePrivateKey.IsRsa)
|
||||
return FallbackImpl.PrivateKey;
|
||||
var bytes = nativePrivateKey.GetBytes (true);
|
||||
return PKCS8.PrivateKeyInfo.DecodeRSA (bytes);
|
||||
}
|
||||
set { FallbackImpl.PrivateKey = value; }
|
||||
set {
|
||||
nativePrivateKey = null;
|
||||
FallbackImpl.PrivateKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override PublicKey PublicKey {
|
||||
@@ -343,6 +353,7 @@ namespace Mono.Btls
|
||||
|
||||
public override void Import (byte[] data, string password, X509KeyStorageFlags keyStorageFlags)
|
||||
{
|
||||
Reset ();
|
||||
if (password == null) {
|
||||
try {
|
||||
Import (data);
|
||||
@@ -399,7 +410,7 @@ namespace Mono.Btls
|
||||
|
||||
x509 = pkcs12.GetCertificate (0);
|
||||
if (pkcs12.HasPrivateKey)
|
||||
privateKey = pkcs12.GetPrivateKey ();
|
||||
nativePrivateKey = pkcs12.GetPrivateKey ();
|
||||
if (pkcs12.Count > 1) {
|
||||
intermediateCerts = new X509CertificateImplCollection ();
|
||||
for (int i = 0; i < pkcs12.Count; i++) {
|
||||
@@ -476,9 +487,8 @@ namespace Mono.Btls
|
||||
x509.Dispose ();
|
||||
x509 = null;
|
||||
}
|
||||
if (privateKey != null) {
|
||||
privateKey = null;
|
||||
privateKey = null;
|
||||
if (nativePrivateKey != null) {
|
||||
nativePrivateKey = null;
|
||||
}
|
||||
subjectName = null;
|
||||
issuerName = null;
|
||||
|
@@ -23,6 +23,7 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Globalization;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
@@ -214,7 +215,7 @@ namespace Mono.Net.Security
|
||||
try {
|
||||
asyncRequest.StartOperation (ProcessHandshake);
|
||||
} catch (Exception ex) {
|
||||
throw SetException (ex);
|
||||
ExceptionDispatchInfo.Capture (SetException (ex)).Throw ();
|
||||
}
|
||||
} finally {
|
||||
if (lazyResult == null || lastException != null) {
|
||||
@@ -241,7 +242,7 @@ namespace Mono.Net.Security
|
||||
|
||||
var e = lazyResult.Result as Exception;
|
||||
if (e != null)
|
||||
throw SetException (e);
|
||||
ExceptionDispatchInfo.Capture (SetException (e)).Throw ();
|
||||
}
|
||||
|
||||
internal void ValidateCreateContext (bool serverMode, string targetHost, SslProtocols enabledProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, bool clientCertRequired)
|
||||
|
@@ -54,7 +54,33 @@ namespace System.Net.NetworkInformation {
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
#if MONODROID
|
||||
[DllImport ("__Internal")]
|
||||
static extern int _monodroid_get_dns_servers (out IntPtr dns_servers_array);
|
||||
|
||||
void GetDNSServersFromOS ()
|
||||
{
|
||||
IntPtr dsa;
|
||||
int len = _monodroid_get_dns_servers (out dsa);
|
||||
if (len <= 0)
|
||||
return;
|
||||
|
||||
var servers = new IntPtr [len];
|
||||
Marshal.Copy (dsa, servers, 0, len);
|
||||
|
||||
dns_servers = new IPAddressCollection ();
|
||||
foreach (IntPtr s in servers) {
|
||||
string server_ip = Marshal.PtrToStringAnsi (s);
|
||||
Marshal.FreeHGlobal (s);
|
||||
|
||||
IPAddress addr;
|
||||
if (!IPAddress.TryParse (server_ip, out addr))
|
||||
continue;
|
||||
dns_servers.InternalAdd (addr);
|
||||
}
|
||||
Marshal.FreeHGlobal (dsa);
|
||||
}
|
||||
#else
|
||||
static Regex ns = new Regex (@"\s*nameserver\s+(?<address>.*)");
|
||||
static Regex search = new Regex (@"\s*search\s+(?<domain>.*)");
|
||||
void ParseResolvConf ()
|
||||
@@ -95,7 +121,7 @@ namespace System.Net.NetworkInformation {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
public override IPAddressInformationCollection AnycastAddresses {
|
||||
get {
|
||||
var c = new IPAddressInformationCollection ();
|
||||
@@ -119,15 +145,23 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
public override IPAddressCollection DnsAddresses {
|
||||
get {
|
||||
#if MONODROID
|
||||
GetDNSServersFromOS ();
|
||||
#else
|
||||
ParseResolvConf ();
|
||||
#endif
|
||||
return dns_servers;
|
||||
}
|
||||
}
|
||||
|
||||
public override string DnsSuffix {
|
||||
get {
|
||||
#if MONODROID
|
||||
return String.Empty;
|
||||
#else
|
||||
ParseResolvConf ();
|
||||
return dns_suffix;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ using System.ComponentModel.Design;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !MOBILE
|
||||
#if !MOBILE && !MONOMAC
|
||||
using System.Drawing.Design;
|
||||
#endif
|
||||
using NUnit.Framework;
|
||||
@@ -1053,7 +1053,7 @@ namespace MonoTests.System.ComponentModel
|
||||
return attr;
|
||||
return null;
|
||||
}
|
||||
#if !MOBILE
|
||||
#if !MOBILE && !MONOMAC
|
||||
class GetEditor_test
|
||||
{
|
||||
[Editor (typeof (UIEditor), typeof (UITypeEditor))]
|
||||
|
@@ -16,7 +16,7 @@ namespace MonoTests.System.ComponentModel
|
||||
[TestFixture]
|
||||
public class ToolboxItemAttributeTests
|
||||
{
|
||||
#if !MOBILE
|
||||
#if !MOBILE && !MONOMAC
|
||||
[Test]
|
||||
public void DefaultType ()
|
||||
{
|
||||
|
@@ -53,7 +53,7 @@ namespace MonoTests.System.Diagnostics
|
||||
public void ConstructorNullName ()
|
||||
{
|
||||
SourceSwitch s = new SourceSwitch (null);
|
||||
Assert.IsEmpty (s.DisplayName);
|
||||
Assert.AreEqual (s.DisplayName.Length, 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// (C) 2003 Martin Willemoes Hansen
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
#if !MOBILE && !MONOMAC
|
||||
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
@@ -29,7 +29,7 @@
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
#if !MOBILE && !MONOMAC
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
// (C) 2005 Novell
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
#if !MOBILE && !MONOMAC
|
||||
|
||||
using System.Net.Configuration;
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
#if !MOBILE && !MONOMAC
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
@@ -1 +1 @@
|
||||
a597b4cd0a240dd08b9f9f2e1722d4a28bcc6754
|
||||
80be0e4eb94d37e9482b76b02caba36592ba91b1
|
Reference in New Issue
Block a user