TLS improvements
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 13h 56m
- Merged PRs (30d)
- 351
Description
Currently if you want to use encryption / authentication between orleans client and orleans servers or between orleans server you can use .UseTls() option in Orleans.Connections.Security.
The TlsOptions wou can provide here has the following public interface:
```cs
public X509Certificate2 LocalCertificate { get; set; }
public Func LocalServerCertificateSelector { get; set; }
public Func LocalClientCertificateSelector { get; set; }
public RemoteCertificateMode RemoteCertificateMode { get; set; }
public RemoteCertificateMode ClientCertificateMode { get; set; }
public RemoteCertificateValidator RemoteCertificateValidation { get; set; }
public SslProtocols SslProtocols { get; set; }
public bool CheckCertificateRevocation { get; set; }
public void AllowAnyRemoteCertificate()
public Action OnAuthenticateAsServer { get; set; }
public Action OnAuthenticateAsClient { get; set; }
```
Te same options are used on the client and the server. Orleans has the following connections:
1. Orleans Client -> Orleans Server (gateway port)
2. Orleans Server -> Orleans Server (silo port)
So an orleans server can receive connections from both clients as other orleans servers. Orleans clients do not receive request but only send out requests. What make it even more difficult if you want to require client certificates for option 2, but not for option 1. Also because some certificate can only be used for ServerAuthentication and some only for ClientAuthentication it makes it a bit unclear.
I would like to suggest redesigning the TlsOptions and adding TlsServerClientOptions make it very clear where certificates are used for and splitting the gateway and silo communication options:
```cs
class TlsOptionOptions {
public TimeSpan HandshakeTimeout { get; set; }
public RemoteCertificateValidator RemoteCertificateValidation { get; set; }
public SslProtocols SslProtocols { get; set; }
public bool CheckCertificateRevocation { get; set; }
public void AllowAnyRemoteCertificate()
public RemoteCertificateMode GatewayRemoteCertificateMode { get; set; }
public X509Certificate2 ClientCertificate { get; set; }
public Func ClientCertificateSelector { get; set; }
public Action OnAuthenticateAsClient { get; set; }
}
class TlsOptionServerOptions : TlsOptionOptions {
public X509Certificate2 ServerCertificate { get; set; }
public Func ServerCertificateSelector { get; set; }
public Action OnAuthenticateAsServer { get; set; }
public RemoteCertificateMode SiloRemoteCertificateMode { get; set; }
}
```
Is there anything I am missing? Would you be open to reviewing a pull request if i would add/refactor this?
TIA,
Bart Vries
Contributor guide
Research direction
Start with the Orleans.Connections.Security implementation behind the UseTls() option and inspect how TlsOptions is applied to gateway and silo connections. Compare the current public interface with the proposed client/server split, then confirm the intended certificate and remote-validation behavior for each connection type. Done means an agreed API design and a reviewed implementation plan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- authentication, distributed-systems, security
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100