Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -156,9 +156,20 @@ namespace Mono.Btls
static Exception GetException (MonoBtlsSslError status)
{
var error = MonoBtlsError.GetError ();
string file;
int line;
var error = MonoBtlsError.GetError (out file, out line);
if (error == 0)
return new MonoBtlsException (status);
var text = MonoBtlsError.GetErrorString (error);
return new MonoBtlsException ("{0} {1}", status, text);
string message;
if (file != null)
message = string.Format ("{0} {1}\n at {2}:{3}", status, text, file, line);
else
message = string.Format ("{0} {1}", status, text);
return new MonoBtlsException (message);
}
public override bool ProcessHandshake ()

View File

@@ -47,6 +47,12 @@ namespace Mono.Btls
[DllImport (MonoBtlsObject.BTLS_DYLIB)]
extern static void mono_btls_error_clear_error ();
[DllImport (MonoBtlsObject.BTLS_DYLIB)]
extern static int mono_btls_error_peek_error_line (out IntPtr file, out int line);
[DllImport (MonoBtlsObject.BTLS_DYLIB)]
extern static int mono_btls_error_get_error_line (out IntPtr file, out int line);
[DllImport (MonoBtlsObject.BTLS_DYLIB)]
extern static void mono_btls_error_get_error_string_n (int error, IntPtr buf, int len);
@@ -78,6 +84,28 @@ namespace Mono.Btls
Marshal.FreeHGlobal (buffer);
}
}
public static int PeekError (out string file, out int line)
{
IntPtr filePtr;
var error = mono_btls_error_peek_error_line (out filePtr, out line);
if (filePtr != IntPtr.Zero)
file = Marshal.PtrToStringAnsi (filePtr);
else
file = null;
return error;
}
public static int GetError (out string file, out int line)
{
IntPtr filePtr;
var error = mono_btls_error_get_error_line (out filePtr, out line);
if (filePtr != IntPtr.Zero)
file = Marshal.PtrToStringAnsi (filePtr);
else
file = null;
return error;
}
}
}
#endif

View File

@@ -33,11 +33,7 @@ namespace Mono.Btls
{
abstract class MonoBtlsObject : IDisposable
{
#if MONO_FEATURE_DYNAMIC_BTLS
internal const string BTLS_DYLIB = "libmono-btls-shared";
#else
internal const string BTLS_DYLIB = "__Internal";
#endif
internal MonoBtlsObject (MonoBtlsHandle handle)
{

View File

@@ -82,17 +82,10 @@ namespace Mono.Btls
[DllImport (BTLS_DYLIB)]
extern static IntPtr mono_btls_x509_lookup_peek_lookup (IntPtr handle);
MonoBtlsX509Store store;
MonoBtlsX509LookupType type;
List<MonoBtlsX509LookupMono> monoLookups;
#if FIXME
// Do we need this?
internal MonoBtlsX509Lookup (BoringX509LookupHandle handle)
: base (handle)
{
}
#endif
static BoringX509LookupHandle Create_internal (MonoBtlsX509Store store, MonoBtlsX509LookupType type)
{
var handle = mono_btls_x509_lookup_new (
@@ -105,6 +98,7 @@ namespace Mono.Btls
internal MonoBtlsX509Lookup (MonoBtlsX509Store store, MonoBtlsX509LookupType type)
: base (Create_internal (store, type))
{
this.store = store;
this.type = type;
}
@@ -151,6 +145,7 @@ namespace Mono.Btls
var ret = mono_btls_x509_lookup_add_mono (
Handle.DangerousGetHandle (), monoLookup.Handle.DangerousGetHandle ());
CheckError (ret);
monoLookup.Install (this);
if (monoLookups == null)
monoLookups = new List<MonoBtlsX509LookupMono> ();
@@ -196,6 +191,11 @@ namespace Mono.Btls
}
}
internal void AddCertificate (MonoBtlsX509 certificate)
{
store.AddCertificate (certificate);
}
protected override void Close ()
{
try {

View File

@@ -67,6 +67,7 @@ namespace Mono.Btls
IntPtr instance;
BySubjectFunc bySubjectFunc;
IntPtr bySubjectFuncPtr;
MonoBtlsX509Lookup lookup;
internal MonoBtlsX509LookupMono ()
: base (new BoringX509LookupMonoHandle (mono_btls_x509_lookup_mono_new ()))
@@ -78,6 +79,18 @@ namespace Mono.Btls
mono_btls_x509_lookup_mono_init (Handle.DangerousGetHandle (), instance, bySubjectFuncPtr);
}
internal void Install (MonoBtlsX509Lookup lookup)
{
if (this.lookup != null)
throw new InvalidOperationException ();
this.lookup = lookup;
}
protected void AddCertificate (MonoBtlsX509 certificate)
{
lookup.AddCertificate (certificate);
}
protected abstract MonoBtlsX509 OnGetBySubject (MonoBtlsX509Name name);
#if MONOTOUCH

View File

@@ -72,12 +72,16 @@ namespace Mono.Btls
Initialize ();
var hash = name.GetHash ();
MonoBtlsX509 found = null;
for (int i = 0; i < certificates.Length; i++) {
if (hashes [i] == hash)
return certificates [i];
if (hashes [i] != hash)
continue;
found = certificates [i];
AddCertificate (found);
}
return null;
return found;
}
protected override void Close ()