| @@ -11,8 +11,13 @@ | ||
| 11 | 11 | |
| 12 | 12 | use phpseclib3\Crypt\RSA; |
| 13 | 13 | use phpseclib3\Crypt\PublicKeyLoader; |
| 14 | 14 | |
| 15 | +// Exit if accessed directly. | |
| 16 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 17 | + exit; | |
| 18 | +} | |
| 19 | + | |
| 15 | 20 | /** |
| 16 | 21 | * Class MainWP_Connect_Lib |
| 17 | 22 | * |
| 18 | 23 | * @package MainWP\Dashboard |
| @@ -92,12 +97,17 @@ | ||
| 92 | 97 | * |
| 93 | 98 | * @param mixed $data The data. |
| 94 | 99 | * @param mixed $signature The signature. |
| 95 | 100 | * @param mixed $privkey The privkey. |
| 101 | + * @param int $site_id site id. | |
| 96 | 102 | */ |
| 97 | - public static function connect_sign( $data, &$signature, $privkey ) { | |
| 103 | + public static function connect_sign( $data, &$signature, $privkey, $site_id ) { | |
| 98 | 104 | try { |
| 99 | - $private = PublicKeyLoader::loadPrivateKey( $privkey ); | |
| 105 | + $de_privkey = MainWP_Encrypt_Data_Lib::instance()->decrypt_privkey( $privkey, $site_id ); | |
| 106 | + if ( empty( $de_privkey ) ) { | |
| 107 | + $de_privkey = $privkey; // compatible. | |
| 108 | + } | |
| 109 | + $private = PublicKeyLoader::loadPrivateKey( $de_privkey ); | |
| 100 | 110 | $signature = $private->sign( $data ); |
| 101 | 111 | if ( ! empty( $signature ) ) { |
| 102 | 112 | return true; |
| 103 | 113 | } |