<?php declare(strict_types = 0);
public static function checkPskOfIdentitiesAmongGivenPairs(array $psk_pairs): void {
$tls_psk_by_identity = [];
foreach ($psk_pairs as $i => $psk_pair) {
if (array_key_exists($psk_pair['tls_psk_identity'], $tls_psk_by_identity)
&& $tls_psk_by_identity[$psk_pair['tls_psk_identity']] !== $psk_pair['tls_psk']) {
throw new APIException(ZBX_API_ERROR_PARAMETERS, _s('Invalid parameter "%1$s": %2$s.',
_('another tls_psk value is already associated with given tls_psk_identity')
$tls_psk_by_identity[$psk_pair['tls_psk_identity']] = $psk_pair['tls_psk'];
public static function checkPskOfIdentitiesInAutoregistration(array $psk_pairs): void {
foreach ($psk_pairs as $i => $psk_pair) {
if (!array_key_exists($psk_pair['tls_psk_identity'], $object_indexes)) {
$object_indexes[$psk_pair['tls_psk_identity']] = $i;
$psk_conditions[] = dbConditionString('tls_psk_identity', [$psk_pair['tls_psk_identity']]).
' AND '.dbConditionString('tls_psk', [$psk_pair['tls_psk']], true);
'SELECT tls_psk_identity'.
' FROM config_autoreg_tls'.
' WHERE ('.implode(') OR (', $psk_conditions).')'
$i = $object_indexes[$row['tls_psk_identity']];
throw new APIException(ZBX_API_ERROR_PARAMETERS, _s('Invalid parameter "%1$s": %2$s.',
'/'.($i + 1).'/tls_psk', _('another tls_psk value is already associated with given tls_psk_identity')
public static function checkPskOfIdentityInAutoregistration(array $psk_pair): void {