[php-src] PR #22057: openssl: Introduce TLS PSK support
| From: | bukka | Date: | Fri, 15 May 2026 17:47:44 +0000 |
| Subject: | [php-src] PR #22057: openssl: Introduce TLS PSK support | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36134@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22057
Author: bukka
Adds pre-shared key authentication for OpenSSL streams, covering both TLS 1.2 (PSK ciphersuites) and
TLS 1.3 (PSK as an external resumed session).
The
Openssl\Psk class is following:
```php
namespace Openssl;
final class Psk {
public const int MAX_PSK_LEN;
public const int MAX_IDENTITY_LEN;
public readonly string $psk;
public readonly ?string $identity;
public function __construct(string $psk, ?string $identity = null);
}
```
Two new options under the ssl context:
- psk_client_cb: callable(resource $stream): ?Openssl\Psk
Called on the client during the handshake to obtain the PSK and identity. Return null
to decline PSK. The returned Psk must have a non-null identity.
- psk_server_cb: callable(resource $stream, string $identity):
?Openssl\Psk
Called on the server with the identity offered by the client. Return null to reject
the identity. Only the key is read from the returned Psk.
For TLS 1.3 servers a default session_id_context is installed when the user does not
supply one, since OpenSSL processes PSK as session resumption and would otherwise reject the
constructed SSL_SESSION with SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED under
the default SSL_VERIFY_PEER configuration. An explicit session_id_context
still takes precedence.
The RFC is not planned unless there are objections as it mirrors the previous Session proposal
including all API decisions from it.