generate key if not existent

This commit is contained in:
Matthias Pfefferle 2023-05-09 12:12:05 +02:00
parent 96953dfc7e
commit 180e882c4a

View file

@ -28,6 +28,10 @@ class Signature {
$key = \get_user_meta( $user_id, 'magic_sig_public_key', true );
}
if ( ! $key ) {
return self::generate_key_pair( $user_id, true );
}
return $key;
}
@ -47,6 +51,10 @@ class Signature {
$key = \get_user_meta( $user_id, 'magic_sig_private_key', true );
}
if ( ! $key ) {
return self::generate_key_pair( $user_id, true );
}
return $key;
}
@ -108,6 +116,8 @@ class Signature {
$signed_string = "(request-target): $http_method $path\nhost: $host\ndate: $date";
}
var_dump($key);
$signature = null;
\openssl_sign( $signed_string, $signature, $key, \OPENSSL_ALGO_SHA256 );
$signature = \base64_encode( $signature ); // phpcs:ignore