I try to generate an ECDH P-256 key pair as required for web push messages.
openssl ecparam -name prime256v1 -genkey -noout -out priv_key.pem
... generates the keys.
openssl ec -noout -text -in priv_key.pem
... looks good: As expected, the private key has 33 bytes, the public key 65. When I export the public key:
openssl ec -in priv_key.pem -pubout -out pub_key.pem
... I expect the base64 output to be 88 characters long - but what I get is 126. The server doesn't accept this key. I read about compressed base64 (https://security.stackexchange.com/a/146515/173609) but this doesn't solve the problem either (it results in an 80 byte base64 string). Anyway I fail to understand how OpenSSL generates this base64 output.