Hello to all ,
we have a private rsa key and a secret phrase,
how can i make a request signed with this?
How to make a request signed with a certificate is known and works for example:
cert, err := tls.LoadX509KeyPair(path+"user.crt", path+"user.key")
if err != nil {
log.Fatal(err)
}
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
}
t := &http.Transport{
TLSClientConfig: tlsConfig,
}
client := &http.Client{
Transport: t,
}
.....
.....
resp, err := client.Do(request)
it worked fineā¦
but how can I do the same thing on Golang?here is a example done on php:
....
$data = json_encode($data);
$privateKey = openssl_pkey_get_private(
file_get_contents(__DIR__ . 'private.pem'),
file_get_contents(__DIR__ . 'password.txt')
);
openssl_sign($data, $sign, $privateKey);
$sign = base64_encode($sign);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'apiurl');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Sign: ' . $sign,
]);
how we can get sign on Golang?