| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | using System.Net.Security; |
| | | 4 | | |
| | | 5 | | namespace IceRpc.Transports.Internal; |
| | | 6 | | |
| | | 7 | | /// <summary>Provides extension methods for <see cref="SslClientAuthenticationOptions" /> and <see |
| | | 8 | | /// cref="SslServerAuthenticationOptions" />.</summary> |
| | | 9 | | /// <remarks>The clone methods copy each property by hand and sit on the security-configuration path: a property |
| | | 10 | | /// added by a future .NET release is not copied and is silently set to its initial value in the user's |
| | | 11 | | /// authentication options. The SslAuthenticationOptionsExtensionsTests reflection tests fail when the .NET |
| | | 12 | | /// property set changes; when they do, add the new property here and to the test's property list.</remarks> |
| | | 13 | | internal static class SslAuthenticationOptionsExtensions |
| | | 14 | | { |
| | | 15 | | /// <summary>Makes a shallow copy of an SSL client authentication options.</summary> |
| | | 16 | | /// <param name="value">The options to copy.</param> |
| | | 17 | | /// <returns>The shallow copy.</returns> |
| | | 18 | | internal static SslClientAuthenticationOptions ShallowClone(this SslClientAuthenticationOptions value) => |
| | 165 | 19 | | new() |
| | 165 | 20 | | { |
| | 165 | 21 | | AllowRenegotiation = value.AllowRenegotiation, |
| | 165 | 22 | | #pragma warning disable CA1416 // Validated at runtime by SslStream |
| | 165 | 23 | | AllowRsaPkcs1Padding = value.AllowRsaPkcs1Padding, |
| | 165 | 24 | | AllowRsaPssPadding = value.AllowRsaPssPadding, |
| | 165 | 25 | | #pragma warning restore CA1416 |
| | 165 | 26 | | AllowTlsResume = value.AllowTlsResume, |
| | 165 | 27 | | ApplicationProtocols = value.ApplicationProtocols, |
| | 165 | 28 | | CertificateChainPolicy = value.CertificateChainPolicy, |
| | 165 | 29 | | CertificateRevocationCheckMode = value.CertificateRevocationCheckMode, |
| | 165 | 30 | | CipherSuitesPolicy = value.CipherSuitesPolicy, |
| | 165 | 31 | | ClientCertificateContext = value.ClientCertificateContext, |
| | 165 | 32 | | ClientCertificates = value.ClientCertificates, |
| | 165 | 33 | | EnabledSslProtocols = value.EnabledSslProtocols, |
| | 165 | 34 | | EncryptionPolicy = value.EncryptionPolicy, |
| | 165 | 35 | | LocalCertificateSelectionCallback = value.LocalCertificateSelectionCallback, |
| | 165 | 36 | | RemoteCertificateValidationCallback = value.RemoteCertificateValidationCallback, |
| | 165 | 37 | | TargetHost = value.TargetHost |
| | 165 | 38 | | }; |
| | | 39 | | |
| | | 40 | | /// <summary>Makes a shallow copy of an SSL server authentication options.</summary> |
| | | 41 | | /// <param name="value">The options to copy.</param> |
| | | 42 | | /// <returns>The shallow copy.</returns> |
| | | 43 | | internal static SslServerAuthenticationOptions ShallowClone(this SslServerAuthenticationOptions value) => |
| | 6 | 44 | | new() |
| | 6 | 45 | | { |
| | 6 | 46 | | AllowRenegotiation = value.AllowRenegotiation, |
| | 6 | 47 | | #pragma warning disable CA1416 // Validated at runtime by SslStream |
| | 6 | 48 | | AllowRsaPkcs1Padding = value.AllowRsaPkcs1Padding, |
| | 6 | 49 | | AllowRsaPssPadding = value.AllowRsaPssPadding, |
| | 6 | 50 | | #pragma warning restore CA1416 |
| | 6 | 51 | | AllowTlsResume = value.AllowTlsResume, |
| | 6 | 52 | | ApplicationProtocols = value.ApplicationProtocols, |
| | 6 | 53 | | CertificateChainPolicy = value.CertificateChainPolicy, |
| | 6 | 54 | | CertificateRevocationCheckMode = value.CertificateRevocationCheckMode, |
| | 6 | 55 | | CipherSuitesPolicy = value.CipherSuitesPolicy, |
| | 6 | 56 | | ClientCertificateRequired = value.ClientCertificateRequired, |
| | 6 | 57 | | EnabledSslProtocols = value.EnabledSslProtocols, |
| | 6 | 58 | | EncryptionPolicy = value.EncryptionPolicy, |
| | 6 | 59 | | RemoteCertificateValidationCallback = value.RemoteCertificateValidationCallback, |
| | 6 | 60 | | ServerCertificate = value.ServerCertificate, |
| | 6 | 61 | | ServerCertificateContext = value.ServerCertificateContext, |
| | 6 | 62 | | ServerCertificateSelectionCallback = value.ServerCertificateSelectionCallback |
| | 6 | 63 | | }; |
| | | 64 | | } |