private CookiesForCannedPolicy CreateSignedCookiesForCannedPolicy() { var privateKeyFileInfo = new FileInfo(PrivateKeyFile); return(AmazonCloudFrontCookieSigner.GetCookiesForCannedPolicy(ResourceUri.ToString(), KeyPairId, privateKeyFileInfo, ExpiresOn)); }
private CookiesForCustomPolicy CreateSignedCookiesForCustomPolicy() { // coreclr StreamReader does not have ctor that takes filename using (var fs = File.OpenRead(PrivateKeyFile)) using (var reader = new StreamReader(fs)) { return(AmazonCloudFrontCookieSigner.GetCookiesForCustomPolicy(ResourceUri.ToString(), reader, KeyPairId, ExpiresOn, ActiveFrom, IpRange)); } }
public static void SetupSignedCookie(string resourceUri) { var keyPairId = Videos.Configs.AwsSettings.cloudFront_keypair; var privateKeyFileName = Videos.Configs.AwsSettings.cloudFront_keyfilename; string pathtokey = SiteConfig.Environment.ContentRootPath + "/wwwroot/security/aws/cloudfront/" + privateKeyFileName; var privateKey = new FileInfo(pathtokey); string distribution = new Uri(resourceUri).Host.TrimEnd('/'); var cookies = AmazonCloudFrontCookieSigner.GetCookiesForCannedPolicy( distribution, keyPairId, privateKey, DateTime.Today.AddYears(1)); Helper.Cookie.WriteCookie(cookies.Expires.Key, cookies.Expires.Value); Helper.Cookie.WriteCookie(cookies.Signature.Key, cookies.Signature.Value); Helper.Cookie.WriteCookie(cookies.KeyPairId.Key, cookies.KeyPairId.Value); }