title: Erlang : convert vapid keys PEM files to base 64 String format (applicationServerKey)
body: <p>Hi I like to send FCM push notifications from erlang server app.
  When user subscribe to FCM notification in browser.  swRegistration.pushManager.subscribe() need a public key (applicationServerKey).</p>
  <p>so to get this key I use openssl and I generate two PEM files private and public keys.</p>
  <pre><code>openssl ecparam -name prime256v1 -genkey -noout -out es_private_key.pem   
  openssl ec -in es_private_key.pem -pubout -out es_public_key.pem
  </code></pre>
  <p>I know thet you can get private and public keys from  firebase  console. But the provided keys are not in
  PEM format and the erlang library that sign JWT <a href="https://github.com/G-Corp/jwerl" rel="nofollow noreferrer">this one</a> use PEM file to sign and verify.</p>
  <pre><code>{ok, PrivtPem} = file:read_file(&quot;path/to/es_private_key.pem&quot;),
  Jwt = jwerl:sign([{name, &lt;&lt;&quot;bob&quot;&gt;&gt;}], es256, PrivtPem).
  </code></pre>
  <p>So from generated private PEM key I can sign JWT but I need the applicationServerKey in base64 String format to add it in headers and also to subscribe user in browser.</p>
  <p>I should convert keys in firebase console to PEMs or convert PEMS to firebase keys format.</p>
  <p>I spend two days to try to do this with Erlang.</p>
  <p>I found haw to do this in Python I need some thing equivalent in erlang.</p>
  <pre><code>raw_pub = vapid.public_key.public_bytes(
                  serialization.Encoding.X962,
                  serialization.PublicFormat.UncompressedPoint
              )
          print(&quot;Application Server Key = {}\n\n&quot;.format(
              b64urlencode(raw_pub)))
  </code></pre>