OpenSSL server is not picking the right cipher

I’ve written an https server in C++ using cpp-httplib (https://github.com/yhirose/cpp-httplib). My requirement is that it needs to work with pre-shared key and cipher DHE-PSK-AES256-CBC-SHA or DHE-PSK-AES256-CBC-SHA384.
I understand those are TLSv1 ciphers that are considered weak, therefore they are somewhat disabled by default.
Here is the relevant part of my code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>httplib::SSLServer *const ssl_server = new httplib::SSLServer([](SSL_CTX &context)
{
SSL_CTX_set_psk_server_callback(&context, psk_callback);
return true;
});
SSL_CTX *const context = ssl_server->ssl_context();
// Section added later, it doesn't work either.
SSL_CTX_set_security_level(context, 0);
SSL_CTX_set_min_proto_version(context, TLS1_VERSION);
SSL_CTX_set_max_proto_version(context, TLS1_VERSION);
SSL_CTX_set_cipher_list(context, "DHE-PSK-AES256-CBC-SHA:DHE-PSK-AES256-CBC-SHA384");
SSL_CTX_set_ciphersuites(context, "");
// End of section added later.
ssl_server->listen("0.0.0.0", 50051);
</code>
<code>httplib::SSLServer *const ssl_server = new httplib::SSLServer([](SSL_CTX &context) { SSL_CTX_set_psk_server_callback(&context, psk_callback); return true; }); SSL_CTX *const context = ssl_server->ssl_context(); // Section added later, it doesn't work either. SSL_CTX_set_security_level(context, 0); SSL_CTX_set_min_proto_version(context, TLS1_VERSION); SSL_CTX_set_max_proto_version(context, TLS1_VERSION); SSL_CTX_set_cipher_list(context, "DHE-PSK-AES256-CBC-SHA:DHE-PSK-AES256-CBC-SHA384"); SSL_CTX_set_ciphersuites(context, ""); // End of section added later. ssl_server->listen("0.0.0.0", 50051); </code>
httplib::SSLServer *const ssl_server = new httplib::SSLServer([](SSL_CTX &context)
{
    SSL_CTX_set_psk_server_callback(&context, psk_callback);

    return true;
});

SSL_CTX *const context = ssl_server->ssl_context();

// Section added later, it doesn't work either.
SSL_CTX_set_security_level(context, 0);
SSL_CTX_set_min_proto_version(context, TLS1_VERSION);
SSL_CTX_set_max_proto_version(context, TLS1_VERSION);

SSL_CTX_set_cipher_list(context, "DHE-PSK-AES256-CBC-SHA:DHE-PSK-AES256-CBC-SHA384");
SSL_CTX_set_ciphersuites(context, "");
// End of section added later.

ssl_server->listen("0.0.0.0", 50051);

The section enclosed between comments has been added later, when I noticed the handshaking was picking more modern ciphers (TLS_CHACHA20_POLY1305_SHA256 and such), which won’t work in the final setup.
I understand a way to test the connection would be with openssl s_client command:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>openssl s_client -connect localhost:50051 -psk ... -tls1 -cipher 'DHE-PSK-AES256-CBC-SHA:@SECLEVEL=0'
</code>
<code>openssl s_client -connect localhost:50051 -psk ... -tls1 -cipher 'DHE-PSK-AES256-CBC-SHA:@SECLEVEL=0' </code>
openssl s_client -connect localhost:50051 -psk ... -tls1 -cipher 'DHE-PSK-AES256-CBC-SHA:@SECLEVEL=0'

Sadly, I get the following output:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>CONNECTED(00000003)
408764833A7B0000:error:0A000410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:../ssl/record/rec_layer_s3.c:1599:SSL alert number 40
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 66 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1
Cipher : 0000
Session-ID:
Session-ID-ctx:
Master-Key:
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1733742579
Timeout : 7200 (sec)
Verify return code: 0 (ok)
Extended master secret: no
---
</code>
<code>CONNECTED(00000003) 408764833A7B0000:error:0A000410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:../ssl/record/rec_layer_s3.c:1599:SSL alert number 40 --- no peer certificate available --- No client certificate CA names sent --- SSL handshake has read 7 bytes and written 66 bytes Verification: OK --- New, (NONE), Cipher is (NONE) Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1 Cipher : 0000 Session-ID: Session-ID-ctx: Master-Key: PSK identity: None PSK identity hint: None SRP username: None Start Time: 1733742579 Timeout : 7200 (sec) Verify return code: 0 (ok) Extended master secret: no --- </code>
CONNECTED(00000003)
408764833A7B0000:error:0A000410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:../ssl/record/rec_layer_s3.c:1599:SSL alert number 40
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 66 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1
    Cipher    : 0000
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: 
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1733742579
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: no
---

If I start a test server with openssl s_server command:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>openssl s_server -accept 50051 -nocert -psk ... -tls1 -cipher "DHE-PSK-AES256-CBC-SHA:@SECLEVEL=0"
</code>
<code>openssl s_server -accept 50051 -nocert -psk ... -tls1 -cipher "DHE-PSK-AES256-CBC-SHA:@SECLEVEL=0" </code>
openssl s_server -accept 50051 -nocert -psk ... -tls1 -cipher "DHE-PSK-AES256-CBC-SHA:@SECLEVEL=0"

The openssl s_client command gives me the following output (which I understand is the one I need for my server):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>CONNECTED(00000003)
Can't use SSL_get_servername
---
no peer certificate available
---
No client certificate CA names sent
Server Temp Key: DH, 3072 bits
---
SSL handshake has read 1131 bytes and written 541 bytes
Verification: OK
---
New, SSLv3, Cipher is DHE-PSK-AES256-CBC-SHA
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1
Cipher : DHE-PSK-AES256-CBC-SHA
Session-ID: 5651AD5A635DFB1E723C1CEE31769765C42930899431C4E8E55694BAA6193756
Session-ID-ctx:
Master-Key: 6771FA4460BF6B1E5D96F4957F6C3B27AFCCDC2F7E3C2676775E02E9FE0DC9B1E3F5AD576AC3BE203D6362876E8347CB
PSK identity: Client_identity
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 7200 (seconds)
TLS session ticket:
0000 - ab 65 ec 02 38 eb 69 27-6e 1f 14 47 b3 aa 17 49 .e..8.i'n..G...I
0010 - b3 59 01 fb 54 33 e1 0a-71 14 d4 cc d8 be 50 e4 .Y..T3..q.....P.
0020 - 35 c1 9d 27 5f 73 60 b1-eb bb 8d 3f 46 50 b8 20 5..'_s`....?FP.
0030 - 44 fa da ff e9 1a cb 52-db 05 49 84 44 a4 e0 09 D......R..I.D...
0040 - 98 18 b0 78 2f c4 2d 89-cf 8a a1 10 5f eb a0 47 ...x/.-....._..G
0050 - 98 b0 c3 b0 51 ed 59 9b-7f 6c e4 40 45 91 13 b6 ....Q.Y..l.@E...
0060 - b8 4c 57 dc 3f 62 d4 aa-2d 39 75 43 16 ef f7 67 .LW.?b..-9uC...g
0070 - 6c e4 b2 1c 6b 70 f0 7d-72 7b 46 2f b0 6b a7 e5 l...kp.}r{F/.k..
0080 - 92 f7 25 1a 63 fa 0c 88-ed be 84 a5 e8 08 6a 60 ..%.c.........j`
0090 - 64 61 1b f1 ed cc 1e 5e-02 b3 02 55 cd c3 17 16 da.....^...U....
00a0 - 67 00 de f4 5e 0d 6f 2b-aa a0 5f fc 1d ce 3b f4 g...^.o+.._...;.
00b0 - ed 51 20 72 5b 0e 02 b6-1f 51 53 3a 8d 19 af dd .Q r[....QS:....
Start Time: 1733744221
Timeout : 7200 (sec)
Verify return code: 0 (ok)
Extended master secret: yes
---
</code>
<code>CONNECTED(00000003) Can't use SSL_get_servername --- no peer certificate available --- No client certificate CA names sent Server Temp Key: DH, 3072 bits --- SSL handshake has read 1131 bytes and written 541 bytes Verification: OK --- New, SSLv3, Cipher is DHE-PSK-AES256-CBC-SHA Secure Renegotiation IS supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1 Cipher : DHE-PSK-AES256-CBC-SHA Session-ID: 5651AD5A635DFB1E723C1CEE31769765C42930899431C4E8E55694BAA6193756 Session-ID-ctx: Master-Key: 6771FA4460BF6B1E5D96F4957F6C3B27AFCCDC2F7E3C2676775E02E9FE0DC9B1E3F5AD576AC3BE203D6362876E8347CB PSK identity: Client_identity PSK identity hint: None SRP username: None TLS session ticket lifetime hint: 7200 (seconds) TLS session ticket: 0000 - ab 65 ec 02 38 eb 69 27-6e 1f 14 47 b3 aa 17 49 .e..8.i'n..G...I 0010 - b3 59 01 fb 54 33 e1 0a-71 14 d4 cc d8 be 50 e4 .Y..T3..q.....P. 0020 - 35 c1 9d 27 5f 73 60 b1-eb bb 8d 3f 46 50 b8 20 5..'_s`....?FP. 0030 - 44 fa da ff e9 1a cb 52-db 05 49 84 44 a4 e0 09 D......R..I.D... 0040 - 98 18 b0 78 2f c4 2d 89-cf 8a a1 10 5f eb a0 47 ...x/.-....._..G 0050 - 98 b0 c3 b0 51 ed 59 9b-7f 6c e4 40 45 91 13 b6 ....Q.Y..l.@E... 0060 - b8 4c 57 dc 3f 62 d4 aa-2d 39 75 43 16 ef f7 67 .LW.?b..-9uC...g 0070 - 6c e4 b2 1c 6b 70 f0 7d-72 7b 46 2f b0 6b a7 e5 l...kp.}r{F/.k.. 0080 - 92 f7 25 1a 63 fa 0c 88-ed be 84 a5 e8 08 6a 60 ..%.c.........j` 0090 - 64 61 1b f1 ed cc 1e 5e-02 b3 02 55 cd c3 17 16 da.....^...U.... 00a0 - 67 00 de f4 5e 0d 6f 2b-aa a0 5f fc 1d ce 3b f4 g...^.o+.._...;. 00b0 - ed 51 20 72 5b 0e 02 b6-1f 51 53 3a 8d 19 af dd .Q r[....QS:.... Start Time: 1733744221 Timeout : 7200 (sec) Verify return code: 0 (ok) Extended master secret: yes --- </code>
CONNECTED(00000003)
Can't use SSL_get_servername
---
no peer certificate available
---
No client certificate CA names sent
Server Temp Key: DH, 3072 bits
---
SSL handshake has read 1131 bytes and written 541 bytes
Verification: OK
---
New, SSLv3, Cipher is DHE-PSK-AES256-CBC-SHA
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1
    Cipher    : DHE-PSK-AES256-CBC-SHA
    Session-ID: 5651AD5A635DFB1E723C1CEE31769765C42930899431C4E8E55694BAA6193756
    Session-ID-ctx: 
    Master-Key: 6771FA4460BF6B1E5D96F4957F6C3B27AFCCDC2F7E3C2676775E02E9FE0DC9B1E3F5AD576AC3BE203D6362876E8347CB
    PSK identity: Client_identity
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 7200 (seconds)
    TLS session ticket:
    0000 - ab 65 ec 02 38 eb 69 27-6e 1f 14 47 b3 aa 17 49   .e..8.i'n..G...I
    0010 - b3 59 01 fb 54 33 e1 0a-71 14 d4 cc d8 be 50 e4   .Y..T3..q.....P.
    0020 - 35 c1 9d 27 5f 73 60 b1-eb bb 8d 3f 46 50 b8 20   5..'_s`....?FP. 
    0030 - 44 fa da ff e9 1a cb 52-db 05 49 84 44 a4 e0 09   D......R..I.D...
    0040 - 98 18 b0 78 2f c4 2d 89-cf 8a a1 10 5f eb a0 47   ...x/.-....._..G
    0050 - 98 b0 c3 b0 51 ed 59 9b-7f 6c e4 40 45 91 13 b6   ....Q.Y..l.@E...
    0060 - b8 4c 57 dc 3f 62 d4 aa-2d 39 75 43 16 ef f7 67   .LW.?b..-9uC...g
    0070 - 6c e4 b2 1c 6b 70 f0 7d-72 7b 46 2f b0 6b a7 e5   l...kp.}r{F/.k..
    0080 - 92 f7 25 1a 63 fa 0c 88-ed be 84 a5 e8 08 6a 60   ..%.c.........j`
    0090 - 64 61 1b f1 ed cc 1e 5e-02 b3 02 55 cd c3 17 16   da.....^...U....
    00a0 - 67 00 de f4 5e 0d 6f 2b-aa a0 5f fc 1d ce 3b f4   g...^.o+.._...;.
    00b0 - ed 51 20 72 5b 0e 02 b6-1f 51 53 3a 8d 19 af dd   .Q r[....QS:....

    Start Time: 1733744221
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: yes
---

I’ve been things for almost a week, but I wasn’t able to make it work with the desired cipher. My knowledge of openssl is just not enough for me to understand what I’m doing wrong. Is anybody able to help me, please?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật