Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -67,8 +67,11 @@ using System.Runtime.InteropServices;
#endif
[assembly: InternalsVisibleTo ("System.ComponentModel.DataAnnotations, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo ("System.Data, PublicKey=00000000000000000400000000000000")]
[assembly: InternalsVisibleTo ("System.Net.Http, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo ("System.Net.Http.WebRequest, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo ("Mono.Btls.Interface, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
@@ -87,3 +90,5 @@ using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo ("Mono.Android, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
#endif
[assembly: TypeForwardedTo (typeof (System.Collections.Generic.Stack<>))]
[assembly: TypeForwardedTo (typeof (System.Collections.Generic.Queue<>))]

View File

@@ -14,24 +14,6 @@ RESOURCE_FILES = \
resources/Question.wav
endif
RESX_EXTRA_ARGUMENTS = \
--in=ReferenceSources/SR.cs \
--in=ReferenceSources/SR2.cs
RESX_RESOURCE_STRING = \
../../../external/corefx/src/System.Collections.Concurrent/src/Resources/Strings.resx \
../../../external/corefx/src/System.Collections/src/Resources/Strings.resx \
../../../external/corefx/src/System.Buffers/src/Resources/Strings.resx \
../../../external/corefx/src/System.Private.Uri/src/Resources/Strings.resx \
../../../external/corefx/src/System.IO.Ports/src/Resources/Strings.resx \
../../../external/corefx/src/System.Net.HttpListener/src/Resources/Strings.resx \
../../../external/corefx/src/System.Net.Requests/src/Resources/Strings.resx \
../../../external/corefx/src/System.Net.Http/src/Resources/Strings.resx \
../../../external/corefx/src/System.Text.RegularExpressions/src/Resources/Strings.resx \
../../../external/corefx/src/System.IO.FileSystem.Watcher/src/Resources/Strings.resx \
../../../external/corefx/src/System.ComponentModel.TypeConverter/src/Resources/Strings.resx \
../../../external/corefx/src/System.Security.Cryptography.Encoding/src/Resources/Strings.resx
TEST_RESOURCE_FILES = \
Test/System/test-uri-props.txt \
Test/System/test-uri-props-manual.txt \
@@ -40,7 +22,7 @@ TEST_RESOURCE_FILES = \
USE_XTEST_REMOTE_EXECUTOR = YES
XTEST_LIB_REFS = System System.Core System.Net Facades/System.Threading.Tasks Facades/System.Runtime.InteropServices.RuntimeInformation System.Net.Http
LIB_MCS_FLAGS = -d:COREFX -d:CONFIGURATION_2_0 -d:XML_DEP -d:SECURITY_DEP $(REFERENCE_SOURCES_FLAGS) -unsafe $(RESOURCE_FILES:%=-resource:%) -nowarn:436
LIB_MCS_FLAGS = -d:COREFX -d:CONFIGURATION_2_0 -d:SYSTEM_NET_PRIMITIVES_DLL -d:XML_DEP -d:SECURITY_DEP $(REFERENCE_SOURCES_FLAGS) -unsafe $(RESOURCE_FILES:%=-resource:%) -nowarn:436
ifndef NO_MONO_SECURITY
MONO_SECURITY := Mono.Security
@@ -92,9 +74,13 @@ endif
ifndef PROFILE_DISABLE_BTLS
ifdef HAVE_BTLS
LIB_MCS_FLAGS += -d:MONO_FEATURE_BTLS
endif
endif
ifdef ENABLE_GSS
ifndef NO_GSS
LIB_MCS_FLAGS += -d:ENABLE_GSS
endif
endif
@@ -116,7 +102,7 @@ endif
TXT_RESOURCE_STRINGS = ../referencesource/System/System.txt
API_BIN_REFS := System.Net.Http System.Xml System.Core
API_BIN_REFS := System.Net.Http System.Xml System.Core System.Numerics
ifndef MOBILE_PROFILE
API_BIN_REFS += System.Configuration

View File

@@ -90,7 +90,15 @@ namespace Microsoft.CSharp
* reset MONO_GC_PARAMS - we are invoking compiler possibly with another GC that
* may not handle some of the options causing compilation failure
*/
mcs.StartInfo.EnvironmentVariables ["MONO_GC_PARAMS"] = String.Empty;
mcs.StartInfo.EnvironmentVariables.Remove ("MONO_GC_PARAMS");
#if XAMMAC_4_5
/*/
* reset MONO_CFG_DIR - we don't want to propagate the current config to another mono
* since it's specific to the XM application and won't work on system mono.
*/
mcs.StartInfo.EnvironmentVariables.Remove ("MONO_CFG_DIR");
#endif
mcs.StartInfo.CreateNoWindow=true;
mcs.StartInfo.UseShellExecute=false;

View File

@@ -50,7 +50,7 @@ namespace Mono.AppleTls
SafeSecIdentityHandle serverIdentity;
SafeSecIdentityHandle clientIdentity;
X509Certificate remoteCertificate;
X509Certificate2 remoteCertificate;
X509Certificate localClientCertificate;
MonoTlsConnectionInfo connectionInfo;
bool isAuthenticated;
@@ -247,7 +247,7 @@ namespace Mono.AppleTls
bool ok;
SecTrust trust = null;
X509CertificateCollection certificates = null;
X509Certificate2Collection certificates = null;
try {
trust = GetPeerTrust (!IsServer);
@@ -261,18 +261,18 @@ namespace Mono.AppleTls
if (trust.Count > 1)
Debug ("WARNING: Got multiple certificates in SecTrust!");
certificates = new X509CertificateCollection ();
certificates = new X509Certificate2Collection ();
for (int i = 0; i < trust.Count; i++)
certificates.Add (trust.GetCertificate (i));
remoteCertificate = new X509Certificate (certificates [0]);
remoteCertificate = new X509Certificate2 (certificates [0]);
Debug ("Got peer trust: {0}", remoteCertificate);
}
ok = ValidateCertificate (certificates);
} catch (Exception ex) {
Debug ("Certificate validation failed: {0}", ex);
throw new TlsException (AlertDescription.CertificateUnknown, "Certificate validation threw exception.");
throw;
} finally {
if (trust != null)
trust.Dispose ();
@@ -395,7 +395,7 @@ namespace Mono.AppleTls
get { return localClientCertificate; }
}
public override X509Certificate RemoteCertificate {
public override X509Certificate2 RemoteCertificate {
get { return remoteCertificate; }
}

View File

@@ -1,5 +1,6 @@
// Copyright 2011-2015 Xamarin Inc. All rights reserved.
using System;
using ObjCRuntimeInternal;
namespace Mono.AppleTls {
@@ -309,10 +310,8 @@ namespace Mono.AppleTls {
VerifyActionFailed = -67825, /* A verify action has failed. */
InvalidCertAuthority = -67826, /* The certificate authority was not valid. */
InvalidCRLAuthority = -67827, /* The CRL authority was not valid. */
#if MONOMAC
[Obsolete ("Use InvalidCRLAuthority")]
InvaldCRLAuthority = InvalidCRLAuthority,
#endif
InvalidCRLEncoding = -67828, /* The CRL encoding was not valid. */
InvalidCRLType = -67829, /* The CRL type was not valid. */
InvalidCRL = -67830, /* The CRL was not valid. */
@@ -338,10 +337,8 @@ namespace Mono.AppleTls {
InvalidTupleGroup = -67850, /* The tuple group was not valid. */
InvalidBaseACLs = -67851, /* The base ACLs are not valid. */
InvalidTupleCredentials = -67852, /* The tuple credentials are not valid. */
#if MONOMAC
[Obsolete ("Use InvalidTupleCredentials")]
InvalidTupleCredendtials = InvalidTupleCredentials,
#endif
InvalidEncoding = -67853, /* The encoding was not valid. */
InvalidValidityPeriod = -67854, /* The validity period was not valid. */
InvalidRequestor = -67855, /* The requestor was not valid. */

View File

@@ -115,7 +115,7 @@ namespace Mono.AppleTls {
[DllImport (AppleTlsContext.SecurityLibrary)]
extern static IntPtr /* SecCertificateRef */ SecTrustGetCertificateAtIndex (IntPtr /* SecTrustRef */ trust, IntPtr /* CFIndex */ ix);
internal X509Certificate GetCertificate (int index)
internal X509Certificate2 GetCertificate (int index)
{
if (handle == IntPtr.Zero)
throw new ObjectDisposedException ("SecTrust");
@@ -124,7 +124,7 @@ namespace Mono.AppleTls {
var ptr = SecTrustGetCertificateAtIndex (handle, (IntPtr)index);
var impl = new X509CertificateImplApple (ptr, false);
return new X509Certificate (impl);
return new X509Certificate2 (impl);
}
[DllImport (AppleTlsContext.SecurityLibrary)]

View File

@@ -1,4 +1,3 @@
#if MONO_FEATURE_APPLETLS || MONO_FEATURE_APPLE_X509
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
@@ -19,7 +18,7 @@ using XamMac.CoreFoundation;
namespace Mono.AppleTls
{
class X509CertificateImplApple : X509CertificateImpl
class X509CertificateImplApple : X509Certificate2ImplUnix
{
IntPtr handle;
X509CertificateImpl fallback;
@@ -57,18 +56,17 @@ namespace Mono.AppleTls
[DllImport (CFHelpers.SecurityLibrary)]
extern static IntPtr SecCertificateCopyData (IntPtr cert);
public override byte[] RawData {
get {
ThrowIfContextInvalid ();
var data = SecCertificateCopyData (handle);
if (data == IntPtr.Zero)
throw new ArgumentException ("Not a valid certificate");
protected override byte[] GetRawCertData ()
{
ThrowIfContextInvalid ();
var data = SecCertificateCopyData (handle);
if (data == IntPtr.Zero)
throw new ArgumentException ("Not a valid certificate");
try {
return CFHelpers.FetchDataBuffer (data);
} finally {
CFHelpers.CFRelease (data);
}
try {
return CFHelpers.FetchDataBuffer (data);
} finally {
CFHelpers.CFRelease (data);
}
}
@@ -81,15 +79,6 @@ namespace Mono.AppleTls
return ret;
}
public override byte[] Thumbprint {
get {
// FIXME: might just return 'null' when 'lazy' is true.
ThrowIfContextInvalid ();
SHA1 sha = SHA1.Create ();
return sha.ComputeHash (RawData);
}
}
public override bool Equals (X509CertificateImpl other, out bool result)
{
var otherAppleImpl = other as X509CertificateImplApple;
@@ -111,52 +100,43 @@ namespace Mono.AppleTls
fallback = new X509Certificate2ImplMono (mxCert);
}
public X509CertificateImpl FallbackImpl {
get {
MustFallback ();
return fallback;
}
#region X509Certificate2Impl implementation
/*
* The AppleTls backend does not support X509Certificate2 yet, so we can safely throw
* PlatformNotSupportedException here.
*/
public override bool HasPrivateKey => throw new PlatformNotSupportedException ();
public override AsymmetricAlgorithm PrivateKey {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public override string Subject => FallbackImpl.Subject;
public override string Issuer => FallbackImpl.Issuer;
public override string LegacySubject => FallbackImpl.LegacySubject;
public override string LegacyIssuer => FallbackImpl.LegacyIssuer;
public override DateTime NotAfter => FallbackImpl.NotAfter;
public override DateTime NotBefore => FallbackImpl.NotBefore;
public override string KeyAlgorithm => FallbackImpl.KeyAlgorithm;
public override byte[] KeyAlgorithmParameters => FallbackImpl.KeyAlgorithmParameters;
public override byte[] PublicKeyValue => FallbackImpl.PublicKeyValue;
public override byte[] SerialNumber => FallbackImpl.SerialNumber;
public override byte[] Export (X509ContentType contentType, SafePasswordHandle password)
public override RSA GetRSAPrivateKey ()
{
ThrowIfContextInvalid ();
switch (contentType) {
case X509ContentType.Cert:
return RawData;
case X509ContentType.Pfx: // this includes Pkcs12
// TODO
throw new NotSupportedException ();
case X509ContentType.SerializedCert:
// TODO
throw new NotSupportedException ();
default:
string msg = Locale.GetText ("This certificate format '{0}' cannot be exported.", contentType);
throw new CryptographicException (msg);
}
throw new PlatformNotSupportedException ();
}
public override DSA GetDSAPrivateKey ()
{
throw new PlatformNotSupportedException ();
}
public override PublicKey PublicKey => throw new PlatformNotSupportedException ();
internal override X509CertificateImplCollection IntermediateCertificates => throw new PlatformNotSupportedException ();
internal override X509Certificate2Impl FallbackImpl => throw new PlatformNotSupportedException ();
public override bool Verify (X509Certificate2 thisCertificate)
{
throw new PlatformNotSupportedException ();
}
#endregion
protected override void Dispose (bool disposing)
{
if (handle != IntPtr.Zero){
@@ -170,4 +150,3 @@ namespace Mono.AppleTls
}
}
}
#endif

View File

@@ -49,7 +49,7 @@ namespace Mono.Btls
{
class MonoBtlsContext : MNS.MobileTlsContext, IMonoBtlsBioMono
{
X509Certificate remoteCertificate;
X509Certificate2 remoteCertificate;
X509Certificate clientCertificate;
X509CertificateImplBtls nativeServerCertificate;
X509CertificateImplBtls nativeClientCertificate;
@@ -79,10 +79,7 @@ namespace Mono.Btls
var password = Guid.NewGuid ().ToString ();
using (var handle = new SafePasswordHandle (password)) {
var buffer = certificate.Export (X509ContentType.Pfx, password);
impl = new X509CertificateImplBtls ();
impl.Import (buffer, handle, X509KeyStorageFlags.DefaultKeySet);
return impl;
return new X509CertificateImplBtls (buffer, handle, X509KeyStorageFlags.DefaultKeySet);
}
}
@@ -202,6 +199,7 @@ namespace Mono.Btls
case MonoBtlsSslError.WantWrite:
return false;
default:
ctx.CheckLastError ();
throw GetException (status);
}
}
@@ -465,7 +463,7 @@ namespace Mono.Btls
internal override X509Certificate LocalClientCertificate {
get { return clientCertificate; }
}
public override X509Certificate RemoteCertificate {
public override X509Certificate2 RemoteCertificate {
get { return remoteCertificate; }
}
public override TlsProtocols NegotiatedProtocol {

View File

@@ -119,15 +119,13 @@ namespace Mono.Btls
return (X509Certificate2Impl)impl.Clone ();
var data = certificate.GetRawCertData ();
return new X509CertificateImplBtls (data, MonoBtlsX509Format.DER, false);
return new X509CertificateImplBtls (data, MonoBtlsX509Format.DER);
}
internal X509Certificate2Impl GetNativeCertificate (
byte[] data, SafePasswordHandle password, X509KeyStorageFlags flags)
{
var impl = new X509CertificateImplBtls (false);
impl.Import (data, password, flags);
return impl;
return new X509CertificateImplBtls (data, password, flags);
}
internal static MonoBtlsX509VerifyParam GetVerifyParam (MonoTlsSettings settings, string targetHost, bool serverMode)
@@ -230,21 +228,33 @@ namespace Mono.Btls
status11 = unchecked((int)0x800B010B);
return;
}
var error = storeCtx.GetError();
if (error != Mono.Btls.MonoBtlsX509Error.OK &
error != Mono.Btls.MonoBtlsX509Error.CRL_NOT_YET_VALID) {
chain.Impl.AddStatus(MapVerifyErrorToChainStatus(error));
status11 = unchecked((int)0x800B010B);
var error = storeCtx.GetError ();
switch (error) {
case Mono.Btls.MonoBtlsX509Error.OK:
errors = MonoSslPolicyErrors.None;
break;
case Mono.Btls.MonoBtlsX509Error.CRL_NOT_YET_VALID:
break;
case MonoBtlsX509Error.HOSTNAME_MISMATCH:
errors = MonoSslPolicyErrors.RemoteCertificateNameMismatch;
chain.Impl.AddStatus (X509ChainStatusFlags.UntrustedRoot);
status11 = unchecked ((int)0x800B010B);
break;
default:
chain.Impl.AddStatus (MapVerifyErrorToChainStatus (error));
status11 = unchecked ((int)0x800B010B);
break;
}
}
internal static X509ChainStatusFlags MapVerifyErrorToChainStatus (MonoBtlsX509Error code)
{
switch (code) {
case MonoBtlsX509Error.OK :
case MonoBtlsX509Error.OK:
return X509ChainStatusFlags.NoError;
case MonoBtlsX509Error.CERT_NOT_YET_VALID :
case MonoBtlsX509Error.CERT_NOT_YET_VALID:
case MonoBtlsX509Error.CERT_HAS_EXPIRED:
case MonoBtlsX509Error.ERROR_IN_CERT_NOT_BEFORE_FIELD:
case MonoBtlsX509Error.ERROR_IN_CERT_NOT_AFTER_FIELD:
@@ -420,33 +430,24 @@ namespace Mono.Btls
#endif
}
public static X509Certificate CreateCertificate (byte[] data, MonoBtlsX509Format format, bool disallowFallback = false)
public static X509Certificate2 CreateCertificate (byte[] data, MonoBtlsX509Format format)
{
using (var impl = new X509CertificateImplBtls (data, format, disallowFallback)) {
return new X509Certificate (impl);
}
}
public static X509Certificate2 CreateCertificate2 (byte[] data, MonoBtlsX509Format format, bool disallowFallback = false)
{
using (var impl = new X509CertificateImplBtls (data, format, disallowFallback)) {
using (var impl = new X509CertificateImplBtls (data, format)) {
return new X509Certificate2 (impl);
}
}
public static X509Certificate2 CreateCertificate2 (byte[] data, string password, bool disallowFallback = false)
public static X509Certificate2 CreateCertificate (byte[] data, string password, bool disallowFallback = false)
{
using (var impl = new X509CertificateImplBtls (disallowFallback))
using (var handle = new SafePasswordHandle (password)) {
impl.Import (data, handle, X509KeyStorageFlags.DefaultKeySet);
using (var handle = new SafePasswordHandle (password))
using (var impl = new X509CertificateImplBtls (data, handle, X509KeyStorageFlags.DefaultKeySet))
return new X509Certificate2 (impl);
}
}
public static X509Certificate CreateCertificate (MonoBtlsX509 x509)
public static X509Certificate2 CreateCertificate (MonoBtlsX509 x509)
{
using (var impl = new X509CertificateImplBtls (x509, true))
return new X509Certificate (impl);
using (var impl = new X509CertificateImplBtls (x509))
return new X509Certificate2 (impl);
}
public static X509Chain CreateChain ()

View File

@@ -310,7 +310,7 @@ namespace Mono.Btls
return mono_btls_x509_get_version (Handle.DangerousGetHandle ());
}
public Oid GetSignatureAlgorithm ()
public string GetSignatureAlgorithm ()
{
int size = 256;
IntPtr data = Marshal.AllocHGlobal (size);
@@ -318,7 +318,7 @@ namespace Mono.Btls
var ret = mono_btls_x509_get_signature_algorithm (
Handle.DangerousGetHandle (), data, size);
CheckError (ret > 0);
return new Oid (Marshal.PtrToStringAnsi (data));
return Marshal.PtrToStringAnsi (data);
} finally {
Marshal.FreeHGlobal (data);
}

View File

@@ -39,6 +39,7 @@ using Mono.Security.Cryptography;
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
@@ -47,249 +48,37 @@ using Microsoft.Win32.SafeHandles;
namespace Mono.Btls
{
class X509CertificateImplBtls : X509Certificate2Impl
class X509CertificateImplBtls : X509Certificate2ImplUnix
{
MonoBtlsX509 x509;
MonoBtlsKey nativePrivateKey;
X500DistinguishedName subjectName;
X500DistinguishedName issuerName;
X509CertificateImplCollection intermediateCerts;
PublicKey publicKey;
bool archived;
bool disallowFallback;
internal X509CertificateImplBtls (bool disallowFallback = false)
internal X509CertificateImplBtls ()
{
this.disallowFallback = disallowFallback;
}
internal X509CertificateImplBtls (MonoBtlsX509 x509, bool disallowFallback = false)
internal X509CertificateImplBtls (MonoBtlsX509 x509)
{
this.disallowFallback = disallowFallback;
this.x509 = x509.Copy ();
}
X509CertificateImplBtls (X509CertificateImplBtls other)
{
disallowFallback = other.disallowFallback;
x509 = other.x509 != null ? other.x509.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 ();
}
internal X509CertificateImplBtls (byte[] data, MonoBtlsX509Format format, bool disallowFallback = false)
internal X509CertificateImplBtls (byte[] data, MonoBtlsX509Format format)
{
this.disallowFallback = disallowFallback;
x509 = MonoBtlsX509.LoadFromData (data, format);
}
public override bool IsValid {
get { return x509 != null && x509.IsValid; }
}
public override IntPtr Handle {
get { return x509.Handle.DangerousGetHandle (); }
}
public override IntPtr GetNativeAppleCertificate ()
internal X509CertificateImplBtls (byte[] data, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
{
return IntPtr.Zero;
}
internal MonoBtlsX509 X509 {
get {
ThrowIfContextInvalid ();
return x509;
}
}
internal MonoBtlsKey NativePrivateKey {
get {
ThrowIfContextInvalid ();
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;
}
}
public override X509CertificateImpl Clone ()
{
ThrowIfContextInvalid ();
return new X509CertificateImplBtls (this);
}
public override bool Equals (X509CertificateImpl other, out bool result)
{
var otherBoringImpl = other as X509CertificateImplBtls;
if (otherBoringImpl == null) {
result = false;
return false;
}
result = MonoBtlsX509.Compare (X509, otherBoringImpl.X509) == 0;
return true;
}
public override byte[] Thumbprint => X509.GetCertHash ();
public override byte[] RawData => X509.GetRawData (MonoBtlsX509Format.DER);
public override string Subject => SubjectName.Name;
public override string Issuer => IssuerName.Name;
public override string LegacySubject => SubjectName.Decode (X500DistinguishedNameFlags.None);
public override string LegacyIssuer => IssuerName.Decode (X500DistinguishedNameFlags.None);
public override DateTime NotBefore => X509.GetNotBefore ().ToLocalTime ();
public override DateTime NotAfter => X509.GetNotAfter ().ToLocalTime ();
public override byte[] PublicKeyValue => X509.GetPublicKeyData ();
public override byte[] SerialNumber => X509.GetSerialNumber (true);
public override string KeyAlgorithm => PublicKey.Oid.Value;
public override byte[] KeyAlgorithmParameters => PublicKey.EncodedParameters.RawData;
internal override X509CertificateImplCollection IntermediateCertificates {
get { return intermediateCerts; }
}
protected override void Dispose (bool disposing)
{
if (x509 != null) {
x509.Dispose ();
x509 = null;
}
}
#region X509Certificate2Impl
X509Certificate2Impl fallback;
void MustFallback ()
{
if (disallowFallback)
throw new InvalidOperationException ();
if (fallback != null)
return;
fallback = SystemDependencyProvider.Instance.CertificateProvider.Import (
RawData, null, X509KeyStorageFlags.DefaultKeySet,
CertificateImportFlags.DisableNativeBackend);
}
internal override X509Certificate2Impl FallbackImpl {
get {
MustFallback ();
return fallback;
}
}
[MonoTODO]
public override bool Archived {
get {
ThrowIfContextInvalid ();
return archived;
}
set {
ThrowIfContextInvalid ();
archived = value;
}
}
public override X509ExtensionCollection Extensions {
get { return FallbackImpl.Extensions; }
}
public override bool HasPrivateKey {
get { return nativePrivateKey != null || FallbackImpl.HasPrivateKey; }
}
public override X500DistinguishedName IssuerName {
get {
ThrowIfContextInvalid ();
if (issuerName == null) {
using (var xname = x509.GetIssuerName ()) {
var encoding = xname.GetRawData (false);
var canonEncoding = xname.GetRawData (true);
var name = MonoBtlsUtils.FormatName (xname, true, ", ", true);
issuerName = new X500DistinguishedName (encoding, canonEncoding, name);
}
}
return issuerName;
}
}
public override AsymmetricAlgorithm PrivateKey {
get {
if (nativePrivateKey == null || !nativePrivateKey.IsRsa)
return FallbackImpl.PrivateKey;
var bytes = nativePrivateKey.GetBytes (true);
return PKCS8.PrivateKeyInfo.DecodeRSA (bytes);
}
set {
if (nativePrivateKey != null)
nativePrivateKey.Dispose ();
nativePrivateKey = null;
FallbackImpl.PrivateKey = value;
}
}
public override PublicKey PublicKey {
get {
ThrowIfContextInvalid ();
if (publicKey == null) {
var keyAsn = X509.GetPublicKeyAsn1 ();
var keyParamAsn = X509.GetPublicKeyParameters ();
publicKey = new PublicKey (keyAsn.Oid, keyParamAsn, keyAsn);
}
return publicKey;
}
}
public override Oid SignatureAlgorithm {
get {
ThrowIfContextInvalid ();
return X509.GetSignatureAlgorithm ();
}
}
public override X500DistinguishedName SubjectName {
get {
ThrowIfContextInvalid ();
if (subjectName == null) {
using (var xname = x509.GetSubjectName ()) {
var encoding = xname.GetRawData (false);
var canonEncoding = xname.GetRawData (true);
var name = MonoBtlsUtils.FormatName (xname, true, ", ", true);
subjectName = new X500DistinguishedName (encoding, canonEncoding, name);
}
}
return subjectName;
}
}
public override int Version {
get { return X509.GetVersion (); }
}
public override string GetNameInfo (X509NameType nameType, bool forIssuer)
{
return FallbackImpl.GetNameInfo (nameType, forIssuer);
}
public override void Import (byte[] data, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
{
Reset ();
if (password == null || password.IsInvalid) {
try {
Import (data);
@@ -320,6 +109,114 @@ namespace Mono.Btls
}
}
public override bool IsValid {
get { return x509 != null && x509.IsValid; }
}
public override IntPtr Handle {
get { return x509.Handle.DangerousGetHandle (); }
}
public override IntPtr GetNativeAppleCertificate ()
{
return IntPtr.Zero;
}
internal MonoBtlsX509 X509 {
get {
ThrowIfContextInvalid ();
return x509;
}
}
internal MonoBtlsKey NativePrivateKey {
get {
ThrowIfContextInvalid ();
return nativePrivateKey;
}
}
public override X509CertificateImpl Clone ()
{
ThrowIfContextInvalid ();
return new X509CertificateImplBtls (this);
}
public override bool Equals (X509CertificateImpl other, out bool result)
{
var otherBoringImpl = other as X509CertificateImplBtls;
if (otherBoringImpl == null) {
result = false;
return false;
}
result = MonoBtlsX509.Compare (X509, otherBoringImpl.X509) == 0;
return true;
}
protected override byte[] GetRawCertData ()
{
ThrowIfContextInvalid ();
return X509.GetRawData (MonoBtlsX509Format.DER);
}
internal override X509CertificateImplCollection IntermediateCertificates {
get { return intermediateCerts; }
}
protected override void Dispose (bool disposing)
{
if (x509 != null) {
x509.Dispose ();
x509 = null;
}
}
#region X509Certificate2Impl
internal override X509Certificate2Impl FallbackImpl => throw new InvalidOperationException ();
public override bool HasPrivateKey => nativePrivateKey != null;
public override AsymmetricAlgorithm PrivateKey {
get {
if (nativePrivateKey == null)
return null;
var bytes = nativePrivateKey.GetBytes (true);
return PKCS8.PrivateKeyInfo.DecodeRSA (bytes);
}
set {
if (nativePrivateKey != null)
nativePrivateKey.Dispose ();
nativePrivateKey = null;
}
}
public override RSA GetRSAPrivateKey ()
{
if (nativePrivateKey == null)
return null;
var bytes = nativePrivateKey.GetBytes (true);
return PKCS8.PrivateKeyInfo.DecodeRSA (bytes);
}
public override DSA GetDSAPrivateKey ()
{
throw new PlatformNotSupportedException ();
}
public override PublicKey PublicKey {
get {
ThrowIfContextInvalid ();
if (publicKey == null) {
var keyAsn = X509.GetPublicKeyAsn1 ();
var keyParamAsn = X509.GetPublicKeyParameters ();
publicKey = new PublicKey (keyAsn.Oid, keyParamAsn, keyAsn);
}
return publicKey;
}
}
void Import (byte[] data)
{
if (data != null) {
@@ -356,7 +253,7 @@ namespace Mono.Btls
using (var ic = pkcs12.GetCertificate (i)) {
if (MonoBtlsX509.Compare (ic, x509) == 0)
continue;
var impl = new X509CertificateImplBtls (ic, true);
var impl = new X509CertificateImplBtls (ic);
intermediateCerts.Add (impl, true);
}
}
@@ -364,56 +261,6 @@ namespace Mono.Btls
}
}
public override byte[] Export (X509ContentType contentType, SafePasswordHandle password)
{
ThrowIfContextInvalid ();
switch (contentType) {
case X509ContentType.Cert:
return RawData;
case X509ContentType.Pfx: // this includes Pkcs12
return ExportPkcs12 (password);
case X509ContentType.SerializedCert:
// TODO
throw new NotSupportedException ();
default:
string msg = Locale.GetText ("This certificate format '{0}' cannot be exported.", contentType);
throw new CryptographicException (msg);
}
}
byte[] ExportPkcs12 (SafePasswordHandle password)
{
if (password == null || password.IsInvalid)
return ExportPkcs12 ((string)null);
var passwordString = password.Mono_DangerousGetString ();
return ExportPkcs12 (passwordString);
}
byte[] ExportPkcs12 (string password)
{
var pfx = new MX.PKCS12 ();
try {
var attrs = new Hashtable ();
var localKeyId = new ArrayList ();
localKeyId.Add (new byte[] { 1, 0, 0, 0 });
attrs.Add (MX.PKCS9.localKeyId, localKeyId);
if (password != null)
pfx.Password = password;
pfx.AddCertificate (new MX.X509Certificate (RawData), attrs);
if (IntermediateCertificates != null) {
for (int i = 0; i < IntermediateCertificates.Count; i++)
pfx.AddCertificate (new MX.X509Certificate (IntermediateCertificates [i].RawData));
}
var privateKey = PrivateKey;
if (privateKey != null)
pfx.AddPkcs8ShroudedKeyBag (privateKey, attrs);
return pfx.GetBytes ();
} finally {
pfx.Password = null;
}
}
public override bool Verify (X509Certificate2 thisCertificate)
{
using (var chain = new MonoBtlsX509Chain ()) {
@@ -438,13 +285,8 @@ namespace Mono.Btls
nativePrivateKey.Dispose ();
nativePrivateKey = null;
}
subjectName = null;
issuerName = null;
archived = false;
publicKey = null;
intermediateCerts = null;
if (fallback != null)
fallback.Reset ();
}
#endregion

View File

@@ -132,7 +132,7 @@ namespace Mono.Btls
public override X509ChainStatus[] ChainStatus {
get {
return chainStatusList.ToArray();
return chainStatusList?.ToArray() ?? new X509ChainStatus[0];
}
}

View File

@@ -1102,29 +1102,64 @@ namespace Mono.Net.Security
}
}
#region Need to Implement
public int CipherStrength {
get {
throw new NotImplementedException ();
CheckThrow (true);
var info = GetConnectionInfo ();
if (info == null)
return 0;
switch (info.CipherAlgorithmType) {
case MSI.CipherAlgorithmType.None:
case MSI.CipherAlgorithmType.Aes128:
case MSI.CipherAlgorithmType.AesGcm128:
return 128;
case MSI.CipherAlgorithmType.Aes256:
case MSI.CipherAlgorithmType.AesGcm256:
return 256;
default:
throw new ArgumentOutOfRangeException (nameof (info.CipherAlgorithmType));
}
}
}
public int HashStrength {
get {
throw new NotImplementedException ();
CheckThrow (true);
var info = GetConnectionInfo ();
if (info == null)
return 0;
switch (info.HashAlgorithmType) {
case MSI.HashAlgorithmType.Md5:
case MSI.HashAlgorithmType.Md5Sha1:
return 128;
case MSI.HashAlgorithmType.Sha1:
return 160;
case MSI.HashAlgorithmType.Sha224:
return 224;
case MSI.HashAlgorithmType.Sha256:
return 256;
case MSI.HashAlgorithmType.Sha384:
return 384;
case MSI.HashAlgorithmType.Sha512:
return 512;
default:
throw new ArgumentOutOfRangeException (nameof (info.HashAlgorithmType));
}
}
}
public int KeyExchangeStrength {
get {
throw new NotImplementedException ();
// FIXME: CoreFX returns 0 on non-Windows platforms.
return 0;
}
}
public bool CheckCertRevocationStatus {
get {
throw new NotImplementedException ();
}
}
#endregion
}
}
#endif

View File

@@ -156,7 +156,7 @@ namespace Mono.Net.Security
get;
}
public abstract X509Certificate RemoteCertificate {
public abstract X509Certificate2 RemoteCertificate {
get;
}
@@ -174,13 +174,13 @@ namespace Mono.Net.Security
public abstract bool PendingRenegotiation ();
protected bool ValidateCertificate (X509Certificate leaf, X509Chain chain)
protected bool ValidateCertificate (X509Certificate2 leaf, X509Chain chain)
{
var result = certificateValidator.ValidateCertificate (TargetHost, IsServer, leaf, chain);
return result != null && result.Trusted && !result.UserDenied;
}
protected bool ValidateCertificate (X509CertificateCollection certificates)
protected bool ValidateCertificate (X509Certificate2Collection certificates)
{
var result = certificateValidator.ValidateCertificate (TargetHost, IsServer, certificates);
return result != null && result.Trusted && !result.UserDenied;

View File

@@ -159,17 +159,16 @@ namespace Mono
if (cert.Impl == null)
return null;
X509Certificate2Impl impl = null;
var impl = cert.Impl as X509Certificate2Impl;
if (impl != null)
return (X509Certificate2Impl)impl.Clone ();
if ((importFlags & CertificateImportFlags.DisableNativeBackend) == 0) {
impl = X509Pal.Import (cert);
if (impl != null)
return impl;
}
impl = cert.Impl as X509Certificate2Impl;
if (impl != null)
return (X509Certificate2Impl)impl.Clone ();
if ((importFlags & CertificateImportFlags.DisableAutomaticFallback) != 0)
return null;

View File

@@ -23,6 +23,13 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
using MonoSecurity::Mono.Security;
#else
using Mono.Security;
#endif
using System;
using System.IO;
using System.Text;
@@ -72,17 +79,66 @@ namespace Mono
{
data = ConvertData (data);
var impl = new X509Certificate2ImplMono ();
using (var handle = new SafePasswordHandle ((string)null))
impl.Import (data, handle, X509KeyStorageFlags.DefaultKeySet);
return impl;
return new X509Certificate2ImplMono (data, handle, X509KeyStorageFlags.DefaultKeySet);
}
internal X509Certificate2Impl ImportFallback (byte[] data, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
{
var impl = new X509Certificate2ImplMono ();
impl.Import (data, password, keyStorageFlags);
return impl;
return new X509Certificate2ImplMono (data, password, keyStorageFlags);
}
public bool SupportsLegacyBasicConstraintsExtension => false;
static byte[] signedData = new byte[] { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02 };
public X509ContentType GetCertContentType (byte[] rawData)
{
if ((rawData == null) || (rawData.Length == 0))
throw new ArgumentException ("rawData");
if (rawData[0] == 0x30) {
// ASN.1 SEQUENCE
try {
ASN1 data = new ASN1 (rawData);
// SEQUENCE / SEQUENCE / BITSTRING
if (data.Count == 3 && data[0].Tag == 0x30 && data[1].Tag == 0x30 && data[2].Tag == 0x03)
return X509ContentType.Cert;
// INTEGER / SEQUENCE / SEQUENCE
if (data.Count == 3 && data[0].Tag == 0x02 && data[1].Tag == 0x30 && data[2].Tag == 0x30)
return X509ContentType.Pkcs12; // note: Pfx == Pkcs12
// check for PKCS#7 (count unknown but greater than 0)
// SEQUENCE / OID (signedData)
if (data.Count > 0 && data[0].Tag == 0x06 && data[0].CompareValue (signedData))
return X509ContentType.Pkcs7;
return X509ContentType.Unknown;
} catch (Exception) {
return X509ContentType.Unknown;
}
} else {
string pem = Encoding.ASCII.GetString (rawData);
int start = pem.IndexOf ("-----BEGIN CERTIFICATE-----");
if (start >= 0)
return X509ContentType.Cert;
}
return X509ContentType.Unknown;
}
public X509ContentType GetCertContentType (string fileName)
{
if (fileName == null)
throw new ArgumentNullException ("fileName");
if (fileName.Length == 0)
throw new ArgumentException ("fileName");
byte[] data = File.ReadAllBytes (fileName);
return GetCertContentType (data);
}
}
}

View File

@@ -122,6 +122,11 @@ namespace System.Net
ArrayList al = new ArrayList ();
string strProxyServer = (string)Microsoft.Win32.Registry.GetValue ("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "ProxyServer", null);
if(strProxyServer == null) {
return null;
}
string strProxyOverrride = (string)Microsoft.Win32.Registry.GetValue ("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "ProxyOverride", null);
if (strProxyServer.Contains ("=")) {

View File

@@ -349,6 +349,7 @@ namespace System.IO.Compression
GCHandle data;
bool disposed;
byte [] io_buffer;
Exception last_error;
private DeflateStreamNative ()
{
@@ -430,7 +431,15 @@ namespace System.IO.Compression
io_buffer = new byte [BufferSize];
int count = Math.Min (length, io_buffer.Length);
int n = base_stream.Read (io_buffer, 0, count);
int n;
try {
n = base_stream.Read (io_buffer, 0, count);
} catch (Exception ex) {
last_error = ex;
return -12;
}
if (n > 0)
Marshal.Copy (io_buffer, 0, buffer, n);
@@ -447,6 +456,7 @@ namespace System.IO.Compression
return self.UnmanagedWrite (buffer, length);
}
int UnmanagedWrite (IntPtr buffer, int length)
{
int total = 0;
@@ -456,7 +466,12 @@ namespace System.IO.Compression
int count = Math.Min (length, io_buffer.Length);
Marshal.Copy (buffer, io_buffer, 0, count);
base_stream.Write (io_buffer, 0, count);
try {
base_stream.Write (io_buffer, 0, count);
} catch (Exception ex) {
last_error = ex;
return -12;
}
unsafe {
buffer = new IntPtr ((byte *) buffer.ToPointer () + count);
}
@@ -466,11 +481,15 @@ namespace System.IO.Compression
return total;
}
static void CheckResult (int result, string where)
void CheckResult (int result, string where)
{
if (result >= 0)
return;
var throw_me = Interlocked.Exchange (ref last_error, null);
if (throw_me != null)
throw throw_me;
string error;
switch (result) {
case -1: // Z_ERRNO
@@ -625,7 +644,11 @@ namespace System.IO.Compression
override protected bool ReleaseHandle()
{
DeflateStreamNative.CloseZStream(handle);
try {
DeflateStreamNative.CloseZStream(handle);
} catch {
;
}
return true;
}
}

View File

@@ -1,4 +1,4 @@
//
//
// System.IO.DefaultWatcher.cs: default IFileWatcher
//
// Authors:
@@ -15,10 +15,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -45,7 +45,7 @@ namespace System.IO {
public DateTime DisabledTime;
public object FilesLock = new object ();
public Hashtable Files;
public Dictionary<string, FileData> Files;
}
class FileData {
@@ -65,7 +65,7 @@ namespace System.IO {
private DefaultWatcher ()
{
}
// Locked by caller
public static bool GetInstance (out IFileWatcher watcher)
{
@@ -78,7 +78,7 @@ namespace System.IO {
watcher = instance;
return true;
}
public void StartDispatching (object handle)
{
var fsw = handle as FileSystemWatcher;
@@ -98,7 +98,7 @@ namespace System.IO {
data = (DefaultWatcherData) watches [fsw];
if (data == null) {
data = new DefaultWatcherData ();
data.Files = new Hashtable ();
data.Files = new Dictionary<string, FileData>();
watches [fsw] = data;
}
@@ -124,7 +124,7 @@ namespace System.IO {
lock (this) {
if (watches == null) return;
}
lock (watches) {
data = (DefaultWatcherData) watches [fsw];
if (data != null) {
@@ -146,7 +146,7 @@ namespace System.IO {
while (true) {
Thread.Sleep (750);
Hashtable my_watches;
lock (watches) {
if (watches.Count == 0) {
@@ -154,10 +154,10 @@ namespace System.IO {
break;
continue;
}
my_watches = (Hashtable) watches.Clone ();
}
if (my_watches.Count != 0) {
zeroes = 0;
foreach (DefaultWatcherData data in my_watches.Values) {
@@ -173,7 +173,7 @@ namespace System.IO {
thread = null;
}
}
bool UpdateDataAndDispatch (DefaultWatcherData data, bool dispatch)
{
if (!data.Enabled) {
@@ -228,16 +228,15 @@ namespace System.IO {
void IterateAndModifyFilesData (DefaultWatcherData data, string directory, bool dispatch, string[] files)
{
/* Set all as untested */
foreach (string filename in data.Files.Keys) {
FileData fd = (FileData) data.Files [filename];
foreach (var entry in data.Files) {
FileData fd = entry.Value;
if (fd.Directory == directory)
fd.NotExists = true;
}
/* New files */
foreach (string filename in files) {
FileData fd = (FileData) data.Files [filename];
if (fd == null) {
if (!data.Files.TryGetValue (filename, out var fd)) {
try {
data.Files.Add (filename, CreateFileData (directory, filename));
} catch {
@@ -245,7 +244,7 @@ namespace System.IO {
data.Files.Remove (filename);
continue;
}
if (dispatch)
DispatchEvents (data.FSW, FileAction.Added, filename);
} else if (fd.Directory == directory) {
@@ -258,8 +257,9 @@ namespace System.IO {
/* Removed files */
List<string> removed = null;
foreach (string filename in data.Files.Keys) {
FileData fd = (FileData) data.Files [filename];
foreach (var entry in data.Files) {
var filename = entry.Key;
FileData fd = entry.Value;
if (fd.NotExists) {
if (removed == null)
removed = new List<string> ();
@@ -277,8 +277,9 @@ namespace System.IO {
}
/* Changed files */
foreach (string filename in data.Files.Keys) {
FileData fd = (FileData) data.Files [filename];
foreach (var entry in data.Files) {
var filename = entry.Key;
FileData fd = entry.Value;
DateTime creation, write;
try {
creation = File.GetCreationTime (filename);
@@ -292,7 +293,7 @@ namespace System.IO {
DispatchEvents (data.FSW, FileAction.Removed, filename);
continue;
}
if (creation != fd.CreationTime || write != fd.LastWriteTime) {
fd.CreationTime = creation;
fd.LastWriteTime = write;
@@ -319,4 +320,3 @@ namespace System.IO {
}
}
}

View File

@@ -0,0 +1,85 @@
//
// System.Net.NetworkInformation.IPInterfaceProperties
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace System.Net.NetworkInformation {
class AixIPInterfaceProperties : UnixIPInterfaceProperties
{
private int _mtu;
public AixIPInterfaceProperties (AixNetworkInterface iface, List <IPAddress> addresses)
: this (iface, addresses, 0)
{
}
public AixIPInterfaceProperties (AixNetworkInterface iface, List <IPAddress> addresses, int mtu)
: base (iface, addresses)
{
_mtu = mtu;
}
public override IPv4InterfaceProperties GetIPv4Properties ()
{
if (ipv4iface_properties == null)
ipv4iface_properties = new AixIPv4InterfaceProperties (iface as AixNetworkInterface, _mtu);
return ipv4iface_properties;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static bool ParseRouteInfo_internal(string iface, out string[] gw_addr_list);
public override GatewayIPAddressInformationCollection GatewayAddresses {
get {
var gateways = new IPAddressCollection ();
string[] gw_addrlist;
if (!ParseRouteInfo_internal (this.iface.Name.ToString(), out gw_addrlist))
return new GatewayIPAddressInformationCollection ();
for(int i=0; i<gw_addrlist.Length; i++) {
try {
IPAddress ip = IPAddress.Parse(gw_addrlist[i]);
if (!ip.Equals (IPAddress.Any) && !gateways.Contains (ip))
gateways.InternalAdd (ip);
} catch (ArgumentNullException) {
/* Ignore this, as the
* internal call might have
* left some blank entries at
* the end of the array
*/
}
}
return SystemGatewayIPAddressInformation.ToGatewayIpAddressInformationCollection (gateways);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More