Skip to content

Commit c0f062e

Browse files
Allow TLS PSK without server certificate
1 parent 39b3fae commit c0f062e

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

ssl/handshake_server.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -793,11 +793,13 @@ static enum ssl_hs_wait_t do_select_certificate(SSL_HANDSHAKE *hs) {
793793
}
794794
}
795795

796-
// Load |hs->local_pubkey| from the cert prematurely. The certificate could be
797-
// subject to change once we negotiate signature algorithms later. If it
798-
// changes to another leaf certificate the server and client has support for,
799-
// we reload it.
800-
if (!ssl_handshake_load_local_pubkey(hs)) {
796+
// Load |hs->local_pubkey| from the cert (if present) prematurely. The
797+
// certificate could be subject to change once we negotiate signature
798+
// algorithms later. If it changes to another leaf certificate the server and
799+
// client has support for, we reload it. The public key may only be absent if
800+
// PSK is enabled on the server, as indicated by presense of a callback.
801+
if (!ssl_handshake_load_local_pubkey(hs) &&
802+
!(hs->local_pubkey == nullptr && hs->config->psk_server_callback)) {
801803
return ssl_hs_error;
802804
}
803805

ssl/ssl_privkey.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ static bool ssl_public_key_rsa_pss_check(EVP_PKEY *pubkey, uint16_t sigalg) {
385385

386386
static bool tls12_pkey_supports_cipher_auth(SSL_HANDSHAKE *hs,
387387
const EVP_PKEY *key) {
388+
GUARD_PTR(key);
388389
SSL *const ssl = hs->ssl;
389390
// We may have a private key that supports the signature algorithm, but we
390391
// need to verify that the negotiated cipher allows it. This behavior is only

tests/ci/integration/python_patch/main/aws-lc-cpython.patch

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,6 @@ index 0e50d09..f4b7b3c 100644
2727
def test_dh_params(self):
2828
# Check we can get a connection with ephemeral Diffie-Hellman
2929
client_context, server_context, hostname = testing_context()
30-
@@ -4364,14 +4366,14 @@ def test_session_handling(self):
31-
def test_psk(self):
32-
psk = bytes.fromhex('deadbeef')
33-
34-
- client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
35-
+ client_context, server_context, _ = testing_context()
36-
+
37-
client_context.check_hostname = False
38-
client_context.verify_mode = ssl.CERT_NONE
39-
client_context.maximum_version = ssl.TLSVersion.TLSv1_2
40-
client_context.set_ciphers('PSK')
41-
client_context.set_psk_client_callback(lambda hint: (None, psk))
42-
43-
- server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
44-
server_context.maximum_version = ssl.TLSVersion.TLSv1_2
45-
server_context.set_ciphers('PSK')
46-
server_context.set_psk_server_callback(lambda identity: psk)
4730
@@ -4443,14 +4445,14 @@ def server_callback(identity):
4831
self.assertEqual(identity, client_identity)
4932
return psk

0 commit comments

Comments
 (0)