From 180e882c4af2803f471ecba42beb3b2d3ea00c70 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 9 May 2023 12:12:05 +0200 Subject: [PATCH] generate key if not existent --- includes/class-signature.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/class-signature.php b/includes/class-signature.php index 1032438..796cb2c 100644 --- a/includes/class-signature.php +++ b/includes/class-signature.php @@ -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