You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
@@ -300,7 +300,7 @@ namespace Mono.Btls
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public override int Read (byte[] buffer, int offset, int size, out bool wantMore)
|
||||
public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int size)
|
||||
{
|
||||
Debug ("Read: {0} {1} {2}", buffer.Length, offset, size);
|
||||
|
||||
@@ -313,27 +313,23 @@ namespace Mono.Btls
|
||||
var status = ssl.Read (data, ref size);
|
||||
Debug ("Read done: {0} {1}", status, size);
|
||||
|
||||
if (status == MonoBtlsSslError.WantRead) {
|
||||
wantMore = true;
|
||||
return 0;
|
||||
} else if (status == MonoBtlsSslError.ZeroReturn) {
|
||||
wantMore = false;
|
||||
return size;
|
||||
} else if (status != MonoBtlsSslError.None) {
|
||||
if (status == MonoBtlsSslError.WantRead)
|
||||
return (0, true);
|
||||
if (status == MonoBtlsSslError.ZeroReturn)
|
||||
return (size, false);
|
||||
if (status != MonoBtlsSslError.None)
|
||||
throw GetException (status);
|
||||
}
|
||||
|
||||
if (size > 0)
|
||||
Marshal.Copy (data, buffer, offset, size);
|
||||
|
||||
wantMore = false;
|
||||
return size;
|
||||
return (size, false);
|
||||
} finally {
|
||||
Marshal.FreeHGlobal (data);
|
||||
}
|
||||
}
|
||||
|
||||
public override int Write (byte[] buffer, int offset, int size, out bool wantMore)
|
||||
public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int size)
|
||||
{
|
||||
Debug ("Write: {0} {1} {2}", buffer.Length, offset, size);
|
||||
|
||||
@@ -347,15 +343,12 @@ namespace Mono.Btls
|
||||
var status = ssl.Write (data, ref size);
|
||||
Debug ("Write done: {0} {1}", status, size);
|
||||
|
||||
if (status == MonoBtlsSslError.WantWrite) {
|
||||
wantMore = true;
|
||||
return 0;
|
||||
} else if (status != MonoBtlsSslError.None) {
|
||||
if (status == MonoBtlsSslError.WantWrite)
|
||||
return (0, true);
|
||||
if (status != MonoBtlsSslError.None)
|
||||
throw GetException (status);
|
||||
}
|
||||
|
||||
wantMore = false;
|
||||
return size;
|
||||
return (size, false);
|
||||
} finally {
|
||||
Marshal.FreeHGlobal (data);
|
||||
}
|
||||
@@ -364,7 +357,8 @@ namespace Mono.Btls
|
||||
public override void Shutdown ()
|
||||
{
|
||||
Debug ("Shutdown!");
|
||||
// ssl.SetQuietShutdown ();
|
||||
if (Settings == null || !Settings.SendCloseNotify)
|
||||
ssl.SetQuietShutdown ();
|
||||
ssl.Shutdown ();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,10 @@ namespace Mono.Btls
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal override bool SupportsCleanShutdown {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override SslProtocols SupportedProtocols {
|
||||
get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
|
||||
}
|
||||
|
||||
@@ -130,6 +130,12 @@ namespace Mono.Btls
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static IntPtr mono_btls_ssl_get_server_name (IntPtr handle);
|
||||
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static void mono_btls_ssl_set_renegotiate_mode (IntPtr handle, int mode);
|
||||
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static int mono_btls_ssl_renegotiate_pending (IntPtr handle);
|
||||
|
||||
static BoringSslHandle Create_internal (MonoBtlsSslCtx ctx)
|
||||
{
|
||||
var handle = mono_btls_ssl_new (ctx.Handle.DangerousGetHandle ());
|
||||
@@ -448,6 +454,17 @@ namespace Mono.Btls
|
||||
if (!Handle.IsInvalid)
|
||||
mono_btls_ssl_close (Handle.DangerousGetHandle ());
|
||||
}
|
||||
|
||||
public void SetRenegotiateMode (MonoBtlsSslRenegotiateMode mode)
|
||||
{
|
||||
CheckThrow ();
|
||||
mono_btls_ssl_set_renegotiate_mode (Handle.DangerousGetHandle (), (int)mode);
|
||||
}
|
||||
|
||||
public bool RenegotiatePending ()
|
||||
{
|
||||
return mono_btls_ssl_renegotiate_pending (Handle.DangerousGetHandle ()) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
39
mcs/class/System/Mono.Btls/MonoBtlsSslRenegotiateMode.cs
Normal file
39
mcs/class/System/Mono.Btls/MonoBtlsSslRenegotiateMode.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// MonoBtlsSslRenegotiateMode.cs
|
||||
//
|
||||
// Author:
|
||||
// Martin Baulig <mabaul@microsoft.com>
|
||||
//
|
||||
// Copyright (c) 2017 Xamarin Inc. (http://www.xamarin.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.
|
||||
#if SECURITY_DEP && MONO_FEATURE_BTLS
|
||||
using System;
|
||||
namespace Mono.Btls
|
||||
{
|
||||
[Flags]
|
||||
enum MonoBtlsSslRenegotiateMode
|
||||
{
|
||||
NEVER = 0,
|
||||
ONCE,
|
||||
FREELY,
|
||||
IGNORE
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -303,6 +303,8 @@ namespace Mono.Btls
|
||||
return PKCS8.PrivateKeyInfo.DecodeRSA (bytes);
|
||||
}
|
||||
set {
|
||||
if (nativePrivateKey != null)
|
||||
nativePrivateKey.Dispose ();
|
||||
nativePrivateKey = null;
|
||||
FallbackImpl.PrivateKey = value;
|
||||
}
|
||||
@@ -490,6 +492,7 @@ namespace Mono.Btls
|
||||
x509 = null;
|
||||
}
|
||||
if (nativePrivateKey != null) {
|
||||
nativePrivateKey.Dispose ();
|
||||
nativePrivateKey = null;
|
||||
}
|
||||
subjectName = null;
|
||||
|
||||
Reference in New Issue
Block a user