diff --git a/Orleans.slnx b/Orleans.slnx
index 5dcc141d8ee..358ddbb1fe7 100644
--- a/Orleans.slnx
+++ b/Orleans.slnx
@@ -61,7 +61,6 @@
-
diff --git a/src/Orleans.Connections.Security/Hosting/HostingExtensions.cs b/src/Orleans.Connections.Security/Hosting/HostingExtensions.cs
deleted file mode 100644
index ecda5bcd286..00000000000
--- a/src/Orleans.Connections.Security/Hosting/HostingExtensions.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Security.Cryptography.X509Certificates;
-using Microsoft.AspNetCore.Connections;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Logging.Abstractions;
-using Orleans.Connections.Security;
-
-namespace Orleans
-{
- public static class TlsConnectionBuilderExtensions
- {
- public static void UseServerTls(
- this IConnectionBuilder builder,
- TlsOptions options)
- {
- if (options is null)
- {
- throw new ArgumentNullException(nameof(options));
- }
-
- var loggerFactory = builder.ApplicationServices.GetService(typeof(ILoggerFactory)) as ILoggerFactory ?? NullLoggerFactory.Instance;
- builder.Use(next =>
- {
- var middleware = new TlsServerConnectionMiddleware(next, options, loggerFactory);
- return middleware.OnConnectionAsync;
- });
- }
-
- public static void UseClientTls(
- this IConnectionBuilder builder,
- TlsOptions options)
- {
- if (options is null)
- {
- throw new ArgumentNullException(nameof(options));
- }
-
- var loggerFactory = builder.ApplicationServices.GetService(typeof(ILoggerFactory)) as ILoggerFactory ?? NullLoggerFactory.Instance;
- builder.Use(next =>
- {
- var middleware = new TlsClientConnectionMiddleware(next, options, loggerFactory);
- return middleware.OnConnectionAsync;
- });
- }
-
- internal static void ThrowNoPrivateKey(X509Certificate2 certificate, string parameterName)
- {
- throw new ArgumentException($"Certificate {certificate.ToString(verbose: true)} does not contain a private key", parameterName);
- }
- }
-}
diff --git a/src/Orleans.Connections.Security/Orleans.Connections.Security.csproj b/src/Orleans.Connections.Security/Orleans.Connections.Security.csproj
deleted file mode 100644
index d60c05ecfaf..00000000000
--- a/src/Orleans.Connections.Security/Orleans.Connections.Security.csproj
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- Microsoft.Orleans.Connections.Security
- Microsoft Orleans TLS support
- Support for security communication using TLS in Microsoft Orleans.
- $(PackageTags) TLS SSL
- $(DefaultTargetFrameworks)
- true
-
-
-
-
-
-
diff --git a/src/Orleans.Connections.Security/Security/CertificateLoader.cs b/src/Orleans.Connections.Security/Security/CertificateLoader.cs
deleted file mode 100644
index 03dad68d208..00000000000
--- a/src/Orleans.Connections.Security/Security/CertificateLoader.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using System;
-using System.Linq;
-using System.Security.Cryptography.X509Certificates;
-
-#nullable disable
-namespace Orleans.Connections.Security
-{
- public static class CertificateLoader
- {
- // See http://oid-info.com/get/1.3.6.1.5.5.7.3.1
- // Indicates that a certificate can be used as a TLS server certificate
- private const string ServerAuthenticationOid = "1.3.6.1.5.5.7.3.1";
-
- // See http://oid-info.com/get/1.3.6.1.5.5.7.3.2
- // Indicates that a certificate can be used as a TLS client certificate
- private const string ClientAuthenticationOid = "1.3.6.1.5.5.7.3.2";
-
- public static X509Certificate2 LoadFromStoreCert(string subject, string storeName, StoreLocation storeLocation, bool allowInvalid, bool server)
- {
- using (var store = new X509Store(storeName, storeLocation))
- {
- X509Certificate2Collection storeCertificates = null;
- X509Certificate2 foundCertificate = null;
-
- try
- {
- store.Open(OpenFlags.ReadOnly);
- storeCertificates = store.Certificates;
- var foundCertificates = storeCertificates.Find(X509FindType.FindBySubjectName, subject, !allowInvalid);
- foundCertificate = foundCertificates
- .OfType()
- .Where(c => server ? IsCertificateAllowedForServerAuth(c) : IsCertificateAllowedForClientAuth(c))
- .Where(DoesCertificateHaveAnAccessiblePrivateKey)
- .OrderByDescending(certificate => certificate.NotAfter)
- .FirstOrDefault();
-
- if (foundCertificate == null)
- {
- throw new InvalidOperationException($"Certificate {subject} not found in store {storeLocation} / {storeName}. AllowInvalid: {allowInvalid}");
- }
-
- return foundCertificate;
- }
- finally
- {
- DisposeCertificates(storeCertificates, except: foundCertificate);
- }
- }
- }
-
- internal static bool IsCertificateAllowedForServerAuth(X509Certificate2 certificate) => IsCertificateAllowedForKeyUsage(certificate, ServerAuthenticationOid);
-
- internal static bool IsCertificateAllowedForClientAuth(X509Certificate2 certificate) => IsCertificateAllowedForKeyUsage(certificate, ClientAuthenticationOid);
-
- private static bool IsCertificateAllowedForKeyUsage(X509Certificate2 certificate, string purposeOid)
- {
- /* If the Extended Key Usage extension is included, then we check that the serverAuth usage is included. (http://oid-info.com/get/1.3.6.1.5.5.7.3.1)
- * If the Extended Key Usage extension is not included, then we assume the certificate is allowed for all usages.
- *
- * See also https://blogs.msdn.microsoft.com/kaushal/2012/02/17/client-certificates-vs-server-certificates/
- *
- * From https://tools.ietf.org/html/rfc3280#section-4.2.1.13 "Certificate Extensions: Extended Key Usage"
- *
- * If the (Extended Key Usage) extension is present, then the certificate MUST only be used
- * for one of the purposes indicated. If multiple purposes are
- * indicated the application need not recognize all purposes indicated,
- * as long as the intended purpose is present. Certificate using
- * applications MAY require that a particular purpose be indicated in
- * order for the certificate to be acceptable to that application.
- */
-
- var hasEkuExtension = false;
-
- foreach (var extension in certificate.Extensions.OfType())
- {
- hasEkuExtension = true;
- foreach (var oid in extension.EnhancedKeyUsages)
- {
- if (oid.Value.Equals(purposeOid, StringComparison.Ordinal))
- {
- return true;
- }
- }
- }
-
- return !hasEkuExtension;
- }
-
- internal static bool DoesCertificateHaveAnAccessiblePrivateKey(X509Certificate2 certificate)
- => certificate.HasPrivateKey;
-
- private static void DisposeCertificates(X509Certificate2Collection certificates, X509Certificate2 except)
- {
- if (certificates != null)
- {
- foreach (var certificate in certificates)
- {
- if (!certificate.Equals(except))
- {
- certificate.Dispose();
- }
- }
- }
- }
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/DuplexPipeStream.cs b/src/Orleans.Connections.Security/Security/DuplexPipeStream.cs
deleted file mode 100644
index 70bfee1387b..00000000000
--- a/src/Orleans.Connections.Security/Security/DuplexPipeStream.cs
+++ /dev/null
@@ -1,279 +0,0 @@
-using System;
-using System.Buffers;
-using System.Diagnostics;
-using System.IO;
-using System.IO.Pipelines;
-using System.Threading;
-using System.Threading.Tasks;
-
-#nullable disable
-namespace Orleans.Connections.Security
-{
- internal class DuplexPipeStream : Stream
- {
- private readonly PipeReader _reader;
- private readonly PipeWriter _writer;
-
- public override bool CanRead => true;
- public override bool CanSeek => false;
- public override bool CanWrite => true;
- public override long Length => throw new NotSupportedException();
- public override long Position { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
-
- public DuplexPipeStream(IDuplexPipe pipe)
- {
- _reader = pipe.Input;
- _writer = pipe.Output;
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- _reader.Complete();
- _writer.Complete();
- }
- base.Dispose(disposing);
- }
-
- public override async ValueTask DisposeAsync()
- {
- await _reader.CompleteAsync().ConfigureAwait(false);
- await _writer.CompleteAsync().ConfigureAwait(false);
- }
-
- public override void Flush()
- {
- FlushAsync().GetAwaiter().GetResult();
- }
-
- public override async Task FlushAsync(CancellationToken cancellationToken)
- {
- FlushResult r = await _writer.FlushAsync(cancellationToken).ConfigureAwait(false);
- if (r.IsCanceled) throw new OperationCanceledException(cancellationToken);
- }
-
- public override int Read(byte[] buffer, int offset, int count)
- {
- ValidateBufferArguments(buffer, offset, count);
-
- ValueTask t = ReadAsync(buffer.AsMemory(offset, count));
- return
- t.IsCompleted ? t.GetAwaiter().GetResult() :
- t.AsTask().GetAwaiter().GetResult();
- }
-
- public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
- {
- ValidateBufferArguments(buffer, offset, count);
-
- return ReadAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask();
- }
-
- public override async ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default)
- {
- ReadResult result = await _reader.ReadAsync(cancellationToken).ConfigureAwait(false);
-
- if (result.IsCanceled)
- {
- throw new OperationCanceledException();
- }
-
- ReadOnlySequence sequence = result.Buffer;
- long bufferLength = sequence.Length;
- SequencePosition consumed = sequence.Start;
-
- try
- {
- if (bufferLength != 0)
- {
- int actual = (int)Math.Min(bufferLength, buffer.Length);
-
- ReadOnlySequence slice = actual == bufferLength ? sequence : sequence.Slice(0, actual);
- consumed = slice.End;
- slice.CopyTo(buffer.Span);
-
- return actual;
- }
-
- if (result.IsCompleted)
- {
- return 0;
- }
- }
- finally
- {
- _reader.AdvanceTo(consumed);
- }
-
- // This is a buggy PipeReader implementation that returns 0 byte reads even though the PipeReader
- // isn't completed or canceled.
- throw new InvalidOperationException("Read zero bytes unexpectedly");
- }
-
- public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
- {
- return TaskToApm.Begin(ReadAsync(buffer, offset, count), callback, state);
- }
-
- public override int EndRead(IAsyncResult asyncResult)
- {
- return TaskToApm.End(asyncResult);
- }
-
- public override long Seek(long offset, SeekOrigin origin)
- {
- throw new NotSupportedException();
- }
-
- public override void SetLength(long value)
- {
- throw new NotSupportedException();
- }
-
- public override void Write(byte[] buffer, int offset, int count)
- {
- WriteAsync(buffer, offset, count, CancellationToken.None).GetAwaiter().GetResult();
- }
-
- public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
- {
- ValidateBufferArguments(buffer, offset, count);
-
- return WriteAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask();
- }
-
- public override async ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default)
- {
- FlushResult r = await _writer.WriteAsync(buffer, cancellationToken).ConfigureAwait(false);
- if (r.IsCanceled) throw new OperationCanceledException(cancellationToken);
- }
-
- public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
- {
- return TaskToApm.Begin(WriteAsync(buffer, offset, count), callback, state);
- }
-
- public override void EndWrite(IAsyncResult asyncResult)
- {
- TaskToApm.End(asyncResult);
- }
-
- public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
- {
- return _reader.CopyToAsync(destination, cancellationToken);
- }
-
- ///
- /// Provides support for efficiently using Tasks to implement the APM (Begin/End) pattern.
- ///
- internal static class TaskToApm
- {
- ///
- /// Marshals the Task as an IAsyncResult, using the supplied callback and state
- /// to implement the APM pattern.
- ///
- /// The Task to be marshaled.
- /// The callback to be invoked upon completion.
- /// The state to be stored in the IAsyncResult.
- /// An IAsyncResult to represent the task's asynchronous operation.
- public static IAsyncResult Begin(Task task, AsyncCallback callback, object state) =>
- new TaskAsyncResult(task, state, callback);
-
- /// Processes an IAsyncResult returned by Begin.
- /// The IAsyncResult to unwrap.
- public static void End(IAsyncResult asyncResult)
- {
- if (GetTask(asyncResult) is Task t)
- {
- t.GetAwaiter().GetResult();
- return;
- }
-
- ThrowArgumentException(asyncResult);
- }
-
- /// Processes an IAsyncResult returned by Begin.
- /// The IAsyncResult to unwrap.
- public static TResult End(IAsyncResult asyncResult)
- {
- if (GetTask(asyncResult) is Task task)
- {
- return task.GetAwaiter().GetResult();
- }
-
- ThrowArgumentException(asyncResult);
- return default!; // unreachable
- }
-
- /// Gets the task represented by the IAsyncResult.
- public static Task GetTask(IAsyncResult asyncResult) => (asyncResult as TaskAsyncResult)?._task;
-
- /// Throws an argument exception for the invalid .
- private static void ThrowArgumentException(IAsyncResult asyncResult) =>
- throw (asyncResult is null ?
- new ArgumentNullException(nameof(asyncResult)) :
- new ArgumentException(null, nameof(asyncResult)));
-
- /// Provides a simple IAsyncResult that wraps a Task.
- ///
- /// We could use the Task as the IAsyncResult if the Task's AsyncState is the same as the object state,
- /// but that's very rare, in particular in a situation where someone cares about allocation, and always
- /// using TaskAsyncResult simplifies things and enables additional optimizations.
- ///
- internal sealed class TaskAsyncResult : IAsyncResult
- {
- /// The wrapped Task.
- internal readonly Task _task;
- /// Callback to invoke when the wrapped task completes.
- private readonly AsyncCallback _callback;
-
- /// Initializes the IAsyncResult with the Task to wrap and the associated object state.
- /// The Task to wrap.
- /// The new AsyncState value.
- /// Callback to invoke when the wrapped task completes.
- internal TaskAsyncResult(Task task, object state, AsyncCallback callback)
- {
- Debug.Assert(task != null);
- _task = task;
- AsyncState = state;
-
- if (task.IsCompleted)
- {
- // Synchronous completion. Invoke the callback. No need to store it.
- CompletedSynchronously = true;
- callback?.Invoke(this);
- }
- else if (callback != null)
- {
- // Asynchronous completion, and we have a callback; schedule it. We use OnCompleted rather than ContinueWith in
- // order to avoid running synchronously if the task has already completed by the time we get here but still run
- // synchronously as part of the task's completion if the task completes after (the more common case).
- _callback = callback;
- _task.ConfigureAwait(continueOnCapturedContext: false)
- .GetAwaiter()
- .OnCompleted(InvokeCallback); // allocates a delegate, but avoids a closure
- }
- }
-
- /// Invokes the callback.
- private void InvokeCallback()
- {
- Debug.Assert(!CompletedSynchronously);
- Debug.Assert(_callback != null);
- _callback.Invoke(this);
- }
-
- /// Gets a user-defined object that qualifies or contains information about an asynchronous operation.
- public object AsyncState { get; }
- /// Gets a value that indicates whether the asynchronous operation completed synchronously.
- /// This is set lazily based on whether the has completed by the time this object is created.
- public bool CompletedSynchronously { get; }
- /// Gets a value that indicates whether the asynchronous operation has completed.
- public bool IsCompleted => _task.IsCompleted;
- /// Gets a that is used to wait for an asynchronous operation to complete.
- public WaitHandle AsyncWaitHandle => ((IAsyncResult)_task).AsyncWaitHandle;
- }
- }
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/DuplexPipeStreamAdapter.cs b/src/Orleans.Connections.Security/Security/DuplexPipeStreamAdapter.cs
deleted file mode 100644
index cdb6985eba5..00000000000
--- a/src/Orleans.Connections.Security/Security/DuplexPipeStreamAdapter.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using System.IO;
-using System.IO.Pipelines;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Orleans.Connections.Security
-{
- ///
- /// A helper for wrapping a Stream decorator from an .
- ///
- ///
- internal class DuplexPipeStreamAdapter : DuplexPipeStream, IDuplexPipe where TStream : Stream
- {
- private bool _disposed;
-#if NET9_0_OR_GREATER
- private readonly Lock _disposeLock = new();
-#else
- private readonly object _disposeLock = new();
-#endif
-
- public DuplexPipeStreamAdapter(IDuplexPipe duplexPipe, Func createStream) :
- this(duplexPipe, new StreamPipeReaderOptions(leaveOpen: true), new StreamPipeWriterOptions(leaveOpen: true), createStream)
- {
- }
-
- public DuplexPipeStreamAdapter(IDuplexPipe duplexPipe, StreamPipeReaderOptions readerOptions, StreamPipeWriterOptions writerOptions, Func createStream) :
- base(duplexPipe)
- {
- var stream = createStream(this);
- Stream = stream;
- Input = PipeReader.Create(stream, readerOptions);
- Output = PipeWriter.Create(stream, writerOptions);
- }
-
- public TStream Stream { get; }
-
- public PipeReader Input { get; }
-
- public PipeWriter Output { get; }
-
- public override async ValueTask DisposeAsync()
- {
- lock (_disposeLock)
- {
- if (_disposed)
- {
- return;
- }
- _disposed = true;
- }
-
- await Input.CompleteAsync();
- await Output.CompleteAsync();
- }
-
- protected override void Dispose(bool disposing)
- {
- lock (_disposeLock)
- {
- if (_disposed)
- {
- return;
- }
- _disposed = true;
- }
-
- if (disposing)
- {
- Input.Complete();
- Output.Complete();
- }
- }
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/ITlsApplicationProtocolFeature.cs b/src/Orleans.Connections.Security/Security/ITlsApplicationProtocolFeature.cs
deleted file mode 100644
index f4c2150640d..00000000000
--- a/src/Orleans.Connections.Security/Security/ITlsApplicationProtocolFeature.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System;
-
-namespace Orleans.Connections.Security
-{
- public interface ITlsApplicationProtocolFeature
- {
- ReadOnlyMemory ApplicationProtocol { get; }
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/ITlsConnectionFeature.cs b/src/Orleans.Connections.Security/Security/ITlsConnectionFeature.cs
deleted file mode 100644
index da981d6113b..00000000000
--- a/src/Orleans.Connections.Security/Security/ITlsConnectionFeature.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Security.Cryptography.X509Certificates;
-using System.Threading.Tasks;
-using System.Threading;
-
-namespace Orleans.Connections.Security
-{
- public interface ITlsConnectionFeature
- {
- ///
- /// Synchronously retrieves the remote endpoint's certificate, if any.
- ///
- X509Certificate2 RemoteCertificate { get; set; }
-
- ///
- /// Asynchronously retrieves the remote endpoint's certificate, if any.
- ///
- ///
- Task GetRemoteCertificateAsync(CancellationToken cancellationToken);
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/ITlsHandshakeFeature.cs b/src/Orleans.Connections.Security/Security/ITlsHandshakeFeature.cs
deleted file mode 100644
index 44324c6c2a1..00000000000
--- a/src/Orleans.Connections.Security/Security/ITlsHandshakeFeature.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Net.Security;
-using System.Security.Authentication;
-
-namespace Orleans.Connections.Security
-{
- public interface ITlsHandshakeFeature
- {
- SslProtocols Protocol { get; }
-
- ///
- /// Gets the .
- ///
- TlsCipherSuite? NegotiatedCipherSuite => null;
-
- ///
- /// Gets the host name from the "server_name" (SNI) extension of the client hello if present.
- ///
- string HostName => string.Empty;
-
-#if NET10_0_OR_GREATER
- [Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties are obsolete. Use NegotiatedCipherSuite instead.", DiagnosticId = "SYSLIB0058", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
-#endif
- CipherAlgorithmType CipherAlgorithm { get; }
-
-#if NET10_0_OR_GREATER
- [Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties are obsolete. Use NegotiatedCipherSuite instead.", DiagnosticId = "SYSLIB0058", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
-#endif
- int CipherStrength { get; }
-
-#if NET10_0_OR_GREATER
- [Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties are obsolete. Use NegotiatedCipherSuite instead.", DiagnosticId = "SYSLIB0058", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
-#endif
- HashAlgorithmType HashAlgorithm { get; }
-
-#if NET10_0_OR_GREATER
- [Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties are obsolete. Use NegotiatedCipherSuite instead.", DiagnosticId = "SYSLIB0058", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
-#endif
- int HashStrength { get; }
-
-#if NET10_0_OR_GREATER
- [Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties are obsolete. Use NegotiatedCipherSuite instead.", DiagnosticId = "SYSLIB0058", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
-#endif
- ExchangeAlgorithmType KeyExchangeAlgorithm { get; }
-
-#if NET10_0_OR_GREATER
- [Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties are obsolete. Use NegotiatedCipherSuite instead.", DiagnosticId = "SYSLIB0058", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
-#endif
- int KeyExchangeStrength { get; }
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/MemoryPoolExtensions.cs b/src/Orleans.Connections.Security/Security/MemoryPoolExtensions.cs
deleted file mode 100644
index 3cbec5de9cc..00000000000
--- a/src/Orleans.Connections.Security/Security/MemoryPoolExtensions.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Buffers;
-
-namespace Orleans.Connections.Security
-{
- internal static class MemoryPoolExtensions
- {
- ///
- /// Computes a minimum segment size
- ///
- ///
- ///
- public static int GetMinimumSegmentSize(this MemoryPool pool)
- {
- if (pool == null)
- {
- return 4096;
- }
-
- return Math.Min(4096, pool.MaxBufferSize);
- }
-
- public static int GetMinimumAllocSize(this MemoryPool pool)
- {
- // 1/2 of a segment
- return pool.GetMinimumSegmentSize() / 2;
- }
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/OrleansApplicationProtocol.cs b/src/Orleans.Connections.Security/Security/OrleansApplicationProtocol.cs
deleted file mode 100644
index 14ab24ceeee..00000000000
--- a/src/Orleans.Connections.Security/Security/OrleansApplicationProtocol.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System.Net.Security;
-
-namespace Orleans.Connections.Security
-{
- internal static class OrleansApplicationProtocol
- {
- public static readonly SslApplicationProtocol Orleans1 = new SslApplicationProtocol("Orleans1");
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/RemoteCertificateMode.cs b/src/Orleans.Connections.Security/Security/RemoteCertificateMode.cs
deleted file mode 100644
index 923ad969f2d..00000000000
--- a/src/Orleans.Connections.Security/Security/RemoteCertificateMode.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace Orleans.Connections.Security
-{
- ///
- /// Describes the remote certificate requirements for a TLS connection.
- ///
- public enum RemoteCertificateMode
- {
- ///
- /// A remote certificate is not required and will not be requested from remote endpoints.
- ///
- NoCertificate,
-
- ///
- /// A remote certificate will be requested; however, authentication will not fail if a certificate is not provided by the remote endpoint.
- ///
- AllowCertificate,
-
- ///
- /// A remote certificate will be requested, and the remote endpoint must provide a valid certificate for authentication.
- ///
- RequireCertificate
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/TlsClientAuthenticationOptions.cs b/src/Orleans.Connections.Security/Security/TlsClientAuthenticationOptions.cs
deleted file mode 100644
index 15d9d02c752..00000000000
--- a/src/Orleans.Connections.Security/Security/TlsClientAuthenticationOptions.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System.Collections.Generic;
-using System.Net.Security;
-using System.Security.Authentication;
-using System.Security.Cryptography.X509Certificates;
-
-#nullable disable
-namespace Orleans.Connections.Security
-{
- public delegate X509Certificate ClientCertificateSelectionCallback(object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers);
-
- public class TlsClientAuthenticationOptions
- {
- internal SslClientAuthenticationOptions Value { get; } = new SslClientAuthenticationOptions
- {
- ApplicationProtocols = new List
- {
- OrleansApplicationProtocol.Orleans1
- }
- };
-
- public ClientCertificateSelectionCallback LocalCertificateSelectionCallback
- {
- get => Value.LocalCertificateSelectionCallback is null ? null : new ClientCertificateSelectionCallback(Value.LocalCertificateSelectionCallback);
- set => Value.LocalCertificateSelectionCallback = value is null ? null : new System.Net.Security.LocalCertificateSelectionCallback(value);
- }
-
- public X509CertificateCollection ClientCertificates
- {
- get => this.Value.ClientCertificates;
- set => this.Value.ClientCertificates = value;
- }
-
- public SslProtocols EnabledSslProtocols
- {
- get => this.Value.EnabledSslProtocols;
- set => this.Value.EnabledSslProtocols = value;
- }
-
- public X509RevocationMode CertificateRevocationCheckMode
- {
- get => this.Value.CertificateRevocationCheckMode;
- set => this.Value.CertificateRevocationCheckMode = value;
- }
-
- public string TargetHost
- {
- get => this.Value.TargetHost;
- set => this.Value.TargetHost = value;
- }
-
- public object SslClientAuthenticationOptions => this.Value;
- }
-}
diff --git a/src/Orleans.Connections.Security/Security/TlsClientConnectionMiddleware.cs b/src/Orleans.Connections.Security/Security/TlsClientConnectionMiddleware.cs
deleted file mode 100644
index 878c316e380..00000000000
--- a/src/Orleans.Connections.Security/Security/TlsClientConnectionMiddleware.cs
+++ /dev/null
@@ -1,262 +0,0 @@
-using System;
-using System.IO.Pipelines;
-using System.Net.Security;
-using System.Security.Cryptography.X509Certificates;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Connections;
-using Microsoft.AspNetCore.Connections.Features;
-using Microsoft.Extensions.Logging;
-
-#nullable disable
-namespace Orleans.Connections.Security
-{
- internal partial class TlsClientConnectionMiddleware
- {
- private readonly ConnectionDelegate _next;
- private readonly TlsOptions _options;
- private readonly ILogger _logger;
- private readonly X509Certificate2 _certificate;
- private readonly Func