Skip to content

Commit

Permalink
empty digest
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiodionisi committed Feb 20, 2019
1 parent 08c5336 commit 0d070ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Satispay <business@satispay.com>
Copyright (c) 2019-present Satispay <business@satispay.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion lib/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Api {
private static $publicKey;
private static $keyId;
private static $securityBearer;
private static $version = "1.0.0";
private static $version = "1.0.1";
private static $authservicesUrl = "https://authservices.satispay.com";

/**
Expand Down
11 changes: 6 additions & 5 deletions lib/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,21 @@ private static function signRequest($options = array()) {

$signature = "(request-target): ".strtolower($options["method"])." ".$options["path"]."\n";
$signature .= "host: ".str_replace("https://", "", Api::getAuthservicesUrl())."\n";
if (!empty($options["body"])) {
$digest = base64_encode(hash("sha256", $options["body"], true));
array_push($headers, "Digest: SHA-256=".$digest);

$digest = base64_encode(hash("sha256", $options["body"], true));
array_push($headers, "Digest: SHA-256=".$digest);
if (!empty($options["body"])) {
$signature .= "content-type: application/json\n";
$signature .= "content-length: ".strlen($options["body"])."\n";
$signature .= "digest: SHA-256=$digest\n";
}
$signature .= "digest: SHA-256=$digest\n";

$signature .= "date: $date";

openssl_sign($signature, $signedSignature, $privateKey, OPENSSL_ALGO_SHA256);
$base64SignedSignature = base64_encode($signedSignature);

$signatureHeaders = "(request-target) host date";
$signatureHeaders = "(request-target) host digest date";
if (!empty($options["body"])) {
$signatureHeaders = "(request-target) host content-type content-length digest date";
}
Expand Down

0 comments on commit 0d070ef

Please sign in to comment.