Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ internal static string[] GetDefaultSignatureAlgorithms()
0x0503 => "ecdsa_secp384r1_sha384",
0x0601 => "rsa_pkcs1_sha512",
0x0603 => "ecdsa_secp521r1_sha512",
0x0708 => "sm2sig_sm3",
0x0804 => "rsa_pss_rsae_sha256",
0x0805 => "rsa_pss_rsae_sha384",
0x0806 => "rsa_pss_rsae_sha512",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Win32.SafeHandles;
using Xunit;

namespace System.Net.Security.Tests;

public class OpenSslErrorTests
{
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsOpenSsl3))]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void ConfigureSignatureAlgorithms_DefaultsAreAccepted(bool enablePss, bool enablePkcs1)
{
Interop.CryptoInitializer.Initialize();
using SafeSslContextHandle context = Interop.Ssl.SslCtxCreate(Interop.Ssl.SslV2_3Method());
Assert.False(context.IsInvalid);
using SafeSslHandle ssl = Interop.Ssl.SslCreate(context);
Assert.False(ssl.IsInvalid);

Interop.OpenSsl.ConfigureSignatureAlgorithms(ssl, enablePss, enablePkcs1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<!-- Linux specific files -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'unix'">
<!-- Linux specific tests -->
<Compile Include="OpenSslErrorTests.cs" />
<Compile Include="SslStreamCertificateContextOcspLinuxTests.cs" />

<Compile Include="..\..\src\System\Net\Security\SslStreamCertificateContext.Linux.cs" />
Expand Down
10 changes: 8 additions & 2 deletions src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ int32_t CryptoNative_SslRenegotiate(SSL* ssl, int32_t* error)
{
ERR_clear_error();

// These are not I/O operations; their failure reasons are on the error queue, not in SSL_get_error.
#if defined NEED_OPENSSL_1_1 || defined NEED_OPENSSL_3_0
// TLS1.3 uses different API for renegotiation/delayed client cert request
#ifndef TLS1_3_VERSION
Expand All @@ -499,7 +500,12 @@ int32_t CryptoNative_SslRenegotiate(SSL* ssl, int32_t* error)
{
// Post-handshake auth reqires SSL_VERIFY_PEER to be set
CryptoNative_SslSetVerifyPeer(ssl);
return SSL_verify_client_post_handshake(ssl);
int ret = SSL_verify_client_post_handshake(ssl);
if (ret != 1)
{
*error = SSL_ERROR_SSL;
}
return ret;
}
else
{
Expand All @@ -518,7 +524,7 @@ int32_t CryptoNative_SslRenegotiate(SSL* ssl, int32_t* error)
int ret = SSL_renegotiate(ssl);
if(ret != 1)
{
*error = CryptoNative_SslGetError(ssl, ret);
*error = SSL_ERROR_SSL;
return ret;
}

Expand Down
Loading