diff --git a/Minio/Credentials/CertificateIdentityProvider.cs b/Minio/Credentials/CertificateIdentityProvider.cs index d6f914e0..6dae299a 100644 --- a/Minio/Credentials/CertificateIdentityProvider.cs +++ b/Minio/Credentials/CertificateIdentityProvider.cs @@ -15,8 +15,8 @@ * limitations under the License. */ + using System.Globalization; -using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Web; @@ -24,6 +24,11 @@ using Minio.DataModel; using Minio.Exceptions; using Minio.Helper; +#if (NET472_OR_GREATER || NET6_0_OR_GREATER) +using System.Security.Authentication; +#else +using System.Net; +#endif /* * Certificate Identity Credential provider. @@ -72,8 +77,7 @@ public async ValueTask GetCredentialsAsync() { var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); using var stream = Encoding.UTF8.GetBytes(content).AsMemory().AsStream(); - certResponse = - Utils.DeserializeXml(stream); + certResponse = Utils.DeserializeXml(stream); } if (Credentials is null && certResponse?.Cr is not null) @@ -118,10 +122,12 @@ public CertificateIdentityProvider Build() builder.Query = query.ToString(); PostEndpoint = builder.Uri; - var handler = new HttpClientHandler - { - ClientCertificateOptions = ClientCertificateOption.Manual, SslProtocols = SslProtocols.Tls12 - }; + var handler = new HttpClientHandler { ClientCertificateOptions = ClientCertificateOption.Manual }; +#if (NET472_OR_GREATER || NET6_0_OR_GREATER) + handler.SslProtocols = SslProtocols.Tls12; +#else + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11; +#endif _ = handler.ClientCertificates.Add(ClientCertificate); HttpClient ??= new HttpClient(handler) { BaseAddress = new Uri(StsEndpoint) };