完善OpenSslSocketsHttpHandler#3
Conversation
|
|
| /// 通过已注册的 DllImportResolver 尝试加载 libssl-3,不抛出异常。 | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// 读取此属性会触发静态构造函数,确保 DllImportResolver 已注册。 |
There was a problem hiding this comment.
- 这里不是属性,而是方法
- 应该不会触发静态构造函数吧,打个断点试试?
|
|
||
| public static bool IsSupported { get; } = OperatingSystem.IsWindows() && OpenSSLNative.IsOpenSslAvailable(); | ||
|
|
||
| public OpenSslAsyncStream(NetworkStream innerStream, bool leaveInnerStreamOpen) |
There was a problem hiding this comment.
感觉这个构造函数的设计不妙,是否可以直接就绕过了?不要再走这里的构造函数进来
There was a problem hiding this comment.
在代理环境下,需要stream套娃。此构造也是stream套娃,保持 NetworkStream 的引用和生命周期同步;而传入 Socket 的构造器反正不是很需要
| private bool _isAuthenticated; | ||
| private bool _disposed; | ||
|
|
||
| public static bool IsSupported { get; } = OperatingSystem.IsWindows() && OpenSSLNative.IsOpenSslAvailable(); |
There was a problem hiding this comment.
这个很棒,可以来做快速分支,只是我想着可以直接用计算的方式,就不用后备字段:
| public static bool IsSupported { get; } = OperatingSystem.IsWindows() && OpenSSLNative.IsOpenSslAvailable(); | |
| public static bool IsSupported => OperatingSystem.IsWindows() && OpenSSLNative.IsOpenSslAvailable(); |
There was a problem hiding this comment.
目前没有做过NativeLibrary.TryLoad的开销计算,IsSupported做为字段存储已计算过的值可以避开不确定的开销。如果不存储已计算过的值,我更倾向于直接设计成IsSupported()方法
| /// OpenSSL 客户端认证配置选项。 | ||
| /// </summary> | ||
| internal sealed class OpenSslClientAuthenticationOptions | ||
| public sealed class OpenSslClientAuthenticationOptions |
There was a problem hiding this comment.
这个是要开放给httphandler做为ssl选项属性
此PR以最大限度地支持ConnectCallback的连接完整性,同时修复了#2