@@ -55,6 +55,7 @@ public override void ExecuteCmdlet()
55
55
{
56
56
LocalResourceIdentifier identifier = new LocalResourceIdentifier ( AuthorizationRuleId ) ;
57
57
string resourceUri = string . Empty , strPolicyName = string . Empty , sakey = string . Empty ;
58
+ DateTime EpochTime = new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Utc ) ;
58
59
59
60
PSListKeysAttributes listkeys ;
60
61
if ( identifier . ParentResource1 != null )
@@ -90,10 +91,12 @@ public override void ExecuteCmdlet()
90
91
}
91
92
}
92
93
93
- string stringToSign = StartTime . HasValue ? StartTime . ToString ( ) + "\n " + System . Web . HttpUtility . UrlEncode ( resourceUri ) + "\n " + ExpiryTime . ToString ( ) : System . Web . HttpUtility . UrlEncode ( resourceUri ) + "\n " + ExpiryTime . ToString ( ) ;
94
+ TimeSpan secondsFromBaseTime = ExpiryTime . Value . Subtract ( EpochTime ) ;
95
+ long seconds = Convert . ToInt64 ( secondsFromBaseTime . TotalSeconds , CultureInfo . InvariantCulture ) ;
96
+ string stringToSign = StartTime . HasValue ? StartTime . ToString ( ) + "\n " + System . Web . HttpUtility . UrlEncode ( resourceUri ) + "\n " + seconds : System . Web . HttpUtility . UrlEncode ( resourceUri ) + "\n " + seconds ;
94
97
HMACSHA256 hmac = new HMACSHA256 ( System . Text . Encoding . UTF8 . GetBytes ( sakey ) ) ;
95
98
var signature = Convert . ToBase64String ( hmac . ComputeHash ( Encoding . UTF8 . GetBytes ( stringToSign ) ) ) ;
96
- string sasToken = String . Format ( CultureInfo . InvariantCulture , "SharedAccessSignature sr={0}&sig={1}&se={2}&skn={3}" , HttpUtility . UrlEncode ( resourceUri ) , HttpUtility . UrlEncode ( signature ) , ExpiryTime , KeyType ) ;
99
+ string sasToken = String . Format ( CultureInfo . InvariantCulture , "SharedAccessSignature sr={0}&sig={1}&se={2}&skn={3}" , HttpUtility . UrlEncode ( resourceUri ) , HttpUtility . UrlEncode ( signature ) , seconds , KeyType ) ;
97
100
PSSharedAccessSignatureAttributes psSastoken = new PSSharedAccessSignatureAttributes ( sasToken ) ;
98
101
WriteObject ( psSastoken , true ) ;
99
102
0 commit comments