Created
April 21, 2020 05:11
-
-
Save jherico/b07f95b1a4e6f19656466de352fea203 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"strings" | |
"github.com/aws/aws-sdk-go/service/cloudfront/sign" | |
"github.com/pkg/errors" | |
"github.com/urfave/cli" | |
) | |
const ( | |
FlagCloudfrontPrivateKey = "cloudfront.signer.private_key" | |
) | |
func runApp(c *cli.Context) error { | |
cloudfrontPrivateKeyAsString := c.String(FlagCloudfrontPrivateKey) | |
fmt.Printf("XXX") | |
fmt.Printf(cloudfrontPrivateKeyAsString) | |
fmt.Printf("XXX") | |
cloudfrontPrivateKey, err := sign.LoadPEMPrivKey(strings.NewReader(cloudfrontPrivateKeyAsString + "\n")) | |
if err != nil { | |
panic(errors.Wrap(err, "failed to cloudfront signer")) | |
} | |
fmt.Println(cloudfrontPrivateKey) | |
return nil | |
} | |
func main() { | |
fmt.Printf("hello, world\n") | |
app := cli.NewApp() | |
app.Name = "app" | |
app.Usage = "Usage" | |
app.Flags = []cli.Flag{ | |
&cli.StringFlag{ | |
Name: FlagCloudfrontPrivateKey, | |
Usage: "Private key for cloudfront url signing", | |
EnvVar: "CLOUDFRONT_SIGNING_PRIVATE_KEY", | |
}, | |
} | |
app.Action = runApp | |
app.Run(os.Args) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment