Skip to content

Commit 5b3ca55

Browse files
committed
fix runtime error: dotnet/standard#530
1 parent 2d1f740 commit 5b3ca55

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/OssClient.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,12 @@ public string GetFileDownloadLink(BucketInfo bucket, string storeKey, int expire
243243
{
244244
long seconds = (DateTime.UtcNow.Ticks - 621355968000000000) / 10000000;
245245

246-
string toSign = String.Format("GET\n\n\n{0}\n/{1}/{2}", seconds, bucket, storeKey);
246+
string toSign = String.Format("GET\n\n\n{0}\n/{1}/{2}", seconds, bucket.BucketName, storeKey);
247247

248248
string sign = ServiceSignature.Create().ComputeSignature(
249249
_requestContext.OssCredential.AccessKeyId, toSign);
250250

251-
string url = String.Format("{0}{1}/{2}?OSSAccessKeyId={3}&Expires={4}&Signature={5}",
252-
bucket.EndpointUri,
253-
bucket,
254-
storeKey,
255-
_requestContext.OssCredential.AccessKeyId,
256-
seconds,
257-
WebUtility.UrlEncode(sign));
251+
string url = $"{bucket.BucketUri}/{storeKey}?OSSAccessKeyId={_requestContext.OssCredential.AccessKeyId}&Expires={seconds}&Signature={WebUtility.UrlEncode(sign)}";
258252

259253
return url;
260254
}

src/Utility/Authentication/HmacSHA1Signature.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ protected override string ComputeSignatureCore(string key, string data)
2424
{
2525
Debug.Assert(!string.IsNullOrEmpty(data));
2626

27-
using (var algorithm = KeyedHashAlgorithm.Create(
28-
SignatureMethod.ToString().ToUpperInvariant()))
27+
//using (var algorithm = KeyedHashAlgorithm.Create(
28+
// SignatureMethod.ToString().ToUpperInvariant()))
29+
//{
30+
// algorithm.Key = _encoding.GetBytes(key.ToCharArray());
31+
// return Convert.ToBase64String(
32+
// algorithm.ComputeHash(_encoding.GetBytes(data.ToCharArray())));
33+
//}
34+
35+
using (var algorithm = new HMACSHA1(_encoding.GetBytes(key.ToCharArray())))
2936
{
30-
algorithm.Key = _encoding.GetBytes(key.ToCharArray());
37+
//algorithm.Key = _encoding.GetBytes(key.ToCharArray());
3138
return Convert.ToBase64String(
3239
algorithm.ComputeHash(_encoding.GetBytes(data.ToCharArray())));
3340
}

0 commit comments

Comments
 (0)