I received an RSA public key from a colleague by way of a pem file:

```
-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEAwGbtPQW6k1S1N8GM4UDxwexV4M+5BHcjs/l397/Mjt/J9+yL4PMw
cdLTnO/PHwCne3DdWsxHoZA/MIHRF+K/d2yDJ8DWHIKtbbUx6/1NOoogauwx+Ush
hNsaT3BCCw+ruFiyPCNKE6JN98hdbiP/61Y9OPZw/9m3c0mMtDv0gtjLJ2Q1z308
DGDZOA3+fTo/PEAgoCycVl0WwwN+AFYsj4DRqIlnxbd0PTSqxVBV+T1oaNmN/8jl
E0zOyQNzOHhDFhJJMucodrUOIFmpWSX6Ff2sVaXY81z4oRq3KrVOK4LZkP6cpPdh
s4Qa6ztWuwJ1ZKK6jOZxF0U2015/4njvgQIDAQAB
-----END RSA PUBLIC KEY-----
```

But when I attempt to encrypt some simple text with it on my Mac

```
openssl rsautl -encrypt -pubin -inkey "/path/to/file/public.pem" -ssl -in "Some text to encrypt with public key" -out /path/to/EncryptedMessage.txt
```

OpenSSL throws exception

```
unable to load Public Key
```

Furthermore, key validation

```
openssl rsa -text -pubin < "/path/to/file/public.pem"
```

also throws exception

```
unable to load Public Key
3106:error:0906D06C:PEM routines:PEM_read_bio:no start line:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-64.50.7/src/crypto/pem/pem_lib.c:648:Expecting: PUBLIC KEY
```

The public key was generated on a Mac and converted to pem

```
ssh-keygen -f ~/.ssh/id_rsa.pub -m 'PEM' -e > public.pem
```

The error message suggests that the public key is not in a valid format. So what am I not understanding and how do I resolve errors?

**Edit**

```
hexdump -C -n64 public.pem
00000000 2d 2d 2d 2d 2d 42 45 47 49 4e 20 52 53 41 20 50 |-----BEGIN RSA P|
00000010 55 42 4c 49 43 20 4b 45 59 2d 2d 2d 2d 2d 0a 4d |UBLIC KEY-----.M|
00000020 49 49 42 43 67 4b 43 41 51 45 41 77 47 62 74 50 |IIBCgKCAQEAwGbtP|
00000030 51 57 36 6b 31 53 31 4e 38 47 4d 34 55 44 78 77 |QW6k1S1N8GM4UDxw|
00000040
```

Appears to be ASCII with no BOM.