Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes .net4.6~.net4.71 framework support issue for ssl protocol setting #799

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dotnet_style_prefer_auto_properties = true:silent
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
end_of_line = lf
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
#*.RTF diff=astextplain
136 changes: 68 additions & 68 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
<Project>
<PropertyGroup>
<Copyright>Copyright (c) Minio. All rights reserved</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/minio/minio-dotnet</PackageProjectUrl>
<Authors>MinIO, Inc.</Authors>
<Owners>MinIO, Inc.</Owners>
<PackageTags>minio;cloud;storage</PackageTags>
<PackageReleaseNotes>https://github.com/minio/minio-dotnet/releases</PackageReleaseNotes>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<NeutralLanguage>en-US</NeutralLanguage>
<MinClientVersion>2.14</MinClientVersion>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/minio/minio-dotnet</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<Version>5.0.1</Version>
<!--<Nullable>enable</Nullable>-->
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<Platform>AnyCPU</Platform>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>Default</AnalysisMode>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<!--<SymbolPackageFormat>snupkg</SymbolPackageFormat>-->
<IncludeSymbols>true</IncludeSymbols>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<DesignTimeBuild>false</DesignTimeBuild>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild Condition=" '$(IsTestProject)' != 'true'">true</GeneratePackageOnBuild>
<PackageIcon>icon.png</PackageIcon>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>
<PackageOutputPath>$(SolutionDir)artifacts</PackageOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
</PropertyGroup>
<ItemGroup Condition=" '$(IsTestProject)' != 'true'">
<None Include="$(MSBuildThisFileDirectory)\LICENSE" Pack="true" PackagePath="\" />
<None Include="$(MSBuildThisFileDirectory)\icon.png" Pack="true" PackagePath="\" />
<None Include="$(MSBuildThisFileDirectory)\readme.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<Project>
<PropertyGroup>
<Copyright>Copyright (c) Minio. All rights reserved</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/minio/minio-dotnet</PackageProjectUrl>
<Authors>MinIO, Inc.</Authors>
<Owners>MinIO, Inc.</Owners>
<PackageTags>minio;cloud;storage</PackageTags>
<PackageReleaseNotes>https://github.com/minio/minio-dotnet/releases</PackageReleaseNotes>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<NeutralLanguage>en-US</NeutralLanguage>
<MinClientVersion>2.14</MinClientVersion>

<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/minio/minio-dotnet</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<Version>5.0.1</Version>

<!--<Nullable>enable</Nullable>-->
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<Platform>AnyCPU</Platform>

<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>Default</AnalysisMode>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<!--<SymbolPackageFormat>snupkg</SymbolPackageFormat>-->
<IncludeSymbols>true</IncludeSymbols>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<DesignTimeBuild>false</DesignTimeBuild>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild Condition=" '$(IsTestProject)' != 'true'">true</GeneratePackageOnBuild>
<PackageIcon>icon.png</PackageIcon>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>

<PackageOutputPath>$(SolutionDir)artifacts</PackageOutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
</PropertyGroup>

<ItemGroup Condition=" '$(IsTestProject)' != 'true'">
<None Include="$(MSBuildThisFileDirectory)\LICENSE" Pack="true" PackagePath="\" />
<None Include="$(MSBuildThisFileDirectory)\icon.png" Pack="true" PackagePath="\" />
<None Include="$(MSBuildThisFileDirectory)\readme.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<!--
<PackageReference Include="Roslynator.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -83,7 +83,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
-->
</ItemGroup>
</Project>
-->
</ItemGroup>

</Project>
19 changes: 13 additions & 6 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 @@ -118,11 +123,13 @@ public CertificateIdentityProvider Build()
builder.Query = query.ToString();
PostEndpoint = builder.ToString();

var handler = new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,
SslProtocols = SslProtocols.Tls12
};
var handler = new HttpClientHandler();
handler.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)
{
Expand Down
Loading