This guide demonstrates how to create asymmetric key pairs for Media CDN.
Generate keys
Command line
You can generate both a private and public key by using Python 3 and OpenSSL 1.1.1 or later (earlier versions of OpenSSL don't support Ed25519).
Generate the private key.
openssl genpkey -algorithm ed25519 -outform PEM -out test.private.key
This outputs a PEM-encoded private key. Keep this key secure, ideally by using a key management system or Secret Manager.
Generate the public key from the private key in URL-safe base64 format.
openssl pkey -outform DER -pubout -in test.private.key | tail -c +13 | python3 -c "import base64, sys; print(('%s' % base64.urlsafe_b64encode(sys.stdin.buffer.read()))[2:-1])"
This command generates the public key from the private key, stripping ASN.1 header information from the raw public key.
Python
With the key in this format, you can now add it to a keyset.
When the keyset is associated with a route as a cdnPolicy.signedRequestKeyset
,
Media CDN validates that the requests were signed before
serving any content.