Question: I`m trying to convert the .cer file to .pem through openssl, the command is:

```
openssl x509 -inform der -in certnew.cer -out ymcert.pem

```

and that's the errors I`m getting:

```
unable to load certificate
140735105180124:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1319:
140735105180124:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:381:Type=X509

```

What am I doing wrong?

Answer: 
I had this problem also. Just rename the CER to PEM was enough :)
no need to convert the file from .cer to .pem you just need to use this command and desired result will be get
**openssl x509 -inform pem -in certificate.cer -pubkey -noout > certificate\_publickey.pem**
it all depends on which encoding type used to generate the certificate as mentioned by @eis