Skip to content
Merged
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 @@ -565,6 +565,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
@@ -1,12 +1,29 @@
// 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);
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsOpenSslSupported))]
// OpenSSL 1.x: ERR_PACK(ERR_LIB_SSL, SSL_F_SSL_VERIFY_CLIENT_POST_HANDSHAKE, SSL_R_EXTENSION_NOT_RECEIVED)
[InlineData(0x14268117u, false, 279)]
Expand Down
5 changes: 3 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 @@ -446,6 +446,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 @@ -458,7 +459,7 @@ int32_t CryptoNative_SslRenegotiate(SSL* ssl, int32_t* error)
int ret = SSL_verify_client_post_handshake(ssl);
if (ret != 1)
{
*error = CryptoNative_SslGetError(ssl, ret);
*error = SSL_ERROR_SSL;
}
return ret;
}
Expand All @@ -474,7 +475,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