|
6 | 6 | using System.Net.Security;
|
7 | 7 | using System.Security.Cryptography.X509Certificates;
|
8 | 8 | using Microsoft.AspNetCore.Server.Kestrel.Core;
|
9 |
| -using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; |
10 | 9 | using Microsoft.AspNetCore.Server.Kestrel.Https;
|
11 | 10 | using Microsoft.AspNetCore.Server.Kestrel.Https.Internal;
|
12 | 11 | using Microsoft.Extensions.DependencyInjection;
|
@@ -235,7 +234,37 @@ public static ListenOptions UseHttps(this ListenOptions listenOptions, HttpsConn
|
235 | 234 | /// </summary>
|
236 | 235 | /// <param name="listenOptions">The <see cref="ListenOptions"/> to configure.</param>
|
237 | 236 | /// <param name="httpsOptionsCallback">Callback to configure HTTPS options.</param>
|
238 |
| - /// <param name="state">State for the <see cref="ServerOptionsSelectionCallback" />.</param> |
| 237 | + /// <param name="state">State for the <paramref name="httpsOptionsCallback"/>.</param> |
| 238 | + /// <returns>The <see cref="ListenOptions"/>.</returns> |
| 239 | + public static ListenOptions UseHttps(this ListenOptions listenOptions, ServerOptionsSelectionCallback httpsOptionsCallback, object state) |
| 240 | + { |
| 241 | + return listenOptions.UseHttps(httpsOptionsCallback, state, HttpsConnectionAdapterOptions.DefaultHandshakeTimeout); |
| 242 | + } |
| 243 | + |
| 244 | + /// <summary> |
| 245 | + /// Configure Kestrel to use HTTPS. |
| 246 | + /// </summary> |
| 247 | + /// <param name="listenOptions">The <see cref="ListenOptions"/> to configure.</param> |
| 248 | + /// <param name="httpsOptionsCallback">Callback to configure HTTPS options.</param> |
| 249 | + /// <param name="state">State for the <paramref name="httpsOptionsCallback"/>.</param> |
| 250 | + /// <param name="handshakeTimeout">Specifies the maximum amount of time allowed for the TLS/SSL handshake. This must be positive and finite.</param> |
| 251 | + /// <returns>The <see cref="ListenOptions"/>.</returns> |
| 252 | + public static ListenOptions UseHttps(this ListenOptions listenOptions, ServerOptionsSelectionCallback httpsOptionsCallback, object state, TimeSpan handshakeTimeout) |
| 253 | + { |
| 254 | + // HttpsOptionsCallback is an internal delegate that is just the ServerOptionsSelectionCallback + a ConnectionContext parameter. |
| 255 | + // Given that ConnectionContext will eventually be replaced by System.Net.Connections, it doesn't make much sense to make the HttpsOptionsCallback delegate public. |
| 256 | + HttpsOptionsCallback adaptedCallback = (connection, stream, clientHelloInfo, state, cancellationToken) => |
| 257 | + httpsOptionsCallback(stream, clientHelloInfo, state, cancellationToken); |
| 258 | + |
| 259 | + return listenOptions.UseHttps(adaptedCallback, state, handshakeTimeout); |
| 260 | + } |
| 261 | + |
| 262 | + /// <summary> |
| 263 | + /// Configure Kestrel to use HTTPS. |
| 264 | + /// </summary> |
| 265 | + /// <param name="listenOptions">The <see cref="ListenOptions"/> to configure.</param> |
| 266 | + /// <param name="httpsOptionsCallback">Callback to configure HTTPS options.</param> |
| 267 | + /// <param name="state">State for the <paramref name="httpsOptionsCallback"/>.</param> |
239 | 268 | /// <param name="handshakeTimeout">Specifies the maximum amount of time allowed for the TLS/SSL handshake. This must be positive and finite.</param>
|
240 | 269 | /// <returns>The <see cref="ListenOptions"/>.</returns>
|
241 | 270 | internal static ListenOptions UseHttps(this ListenOptions listenOptions, HttpsOptionsCallback httpsOptionsCallback, object state, TimeSpan handshakeTimeout)
|
|
0 commit comments