Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Minio/Credentials/CertificateIdentityProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@
* limitations under the License.
*/


using System.Globalization;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Web;
using CommunityToolkit.HighPerformance;
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.
Expand Down Expand Up @@ -72,8 +77,7 @@ public async ValueTask<AccessCredentials> GetCredentialsAsync()
{
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
using var stream = Encoding.UTF8.GetBytes(content).AsMemory().AsStream();
certResponse =
Utils.DeserializeXml<CertificateResponse>(stream);
certResponse = Utils.DeserializeXml<CertificateResponse>(stream);
}

if (Credentials is null && certResponse?.Cr is not null)
Expand Down Expand Up @@ -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) };

Expand Down