-
Notifications
You must be signed in to change notification settings - Fork 0
Description
I've add SSL certification along with .pem file and .crt file to create wallet but Its getting errors. Here how the command to create wallet.
curl -X POST https://localhost:8090/api/v1/wallets -H "Accept: application/json; charset=utf-8" -H "Content-Type: application/json; charset=utf-8" --cert ./state-wallet-mainnet/tls/client/client.pem --cacert ./state-wallet-mainnet/tls/server/ca.crt -d '{"operation":"create",
"backupPhrase"["lake","spot","inquiry","aspect","wear","upper","saddle","helmet","dream","alter","lounge","brain"],"assuranceLevel": "normal","name":"MyFirstWallet","spendingPassword":"5416b2988745725998907addf4613c9b0764f04959030e1b81c603b920a115d0"}'
---------------------So in my php code I've written this-----------------------------------------------------------------
Class Cardano {
const pem= "client.pem";
const client_key = "client.key";
const cert_file = "ca.crt";
public function createWallet(array $body): array
{
return self::jsonDecode($this->post('/api/v1/wallets/',$body),true);
}
private function post(string $endPoint, $postFields = []): string
{
// print_r($endPoint);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->host.$endPoint);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_PORT, $this->port);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postFields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// The --cacert option
curl_setopt($ch, CURLOPT_CAINFO,Cardano::cert_file);
// The --cert option
curl_setopt($ch, CURLOPT_SSLCERT, Cardano::pem);
// The --key option
//curl_setopt($ch, CURLOPT_SSLKEY, Cardano::client_key);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
$headers = [
"Cache-Control: no-cache",
"Content-Type: application/json;charset=utf-8",
"Postman-Token: b71b609e-e028-d78b-ce51-3d0ec0b5c9fb",
"accept: application/json;charset=utf-8"
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
if($this->disableSSLVerification)
{
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
}
$data = curl_exec ($ch);
//print_r($data);
$this->httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if(curl_exec($ch) === false)
{
throw new Exception('Curl error: ' . curl_error($ch));
}
curl_close ($ch);
return $data;
}
}
$body = array('backupPhrase' => array("edge","few","say","stereo","post","blossom","kangaroo","toilet","melody","curtain","fix","room"),'assuranceLevel'=>'normal','name'=>'Wallet','spendingPassword'=>'5416b2988745725998907addf4613c9b0764f04959030e1b81c603b920a115d0');
print_r($client->createWallet($body));
--------------------------------But It generates errors----------------------------------------------
