Q:

Java: Problems reading a public key from a yaml config file

I have a yaml config file which stores a rsa public key
http_authenticator:
          type: jwt
          challenge: false
          config:
            signing_key: >
                  -----BEGIN PUBLIC KEY-----
                  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApJubKdzjmxriryviTEPN
                  85qX8SzcDbseBjJXJzrt3Xn0mk7+7ZxWDnB5Qh/TvZoHGOcaVeoRIzBi1AdX20az
                  x7oAzfMLI48sDEptwJgd87Mg6UmvXlPOkvRypUSP8pFrOUg+aQ75qRsQkXBBWMIO
                  qBZiDXVrMHY1+Q1LOJR1aWFjIlL1WNZecTNJ9UfPhjxW7WJRmI3/EXPbD/OEeC7J
                  mD/nifofYUQUavggcirKI0KM17ENLdyZy3aWfpKOXqZJByfbp5AXmWoWcNZqsiHy
                  KL/sK/nmX86jwKRHvIOQv9IBlPCNSxNr6IQox/BHqZssvY2J65UHOaTJ408x7IQT
                  FQIDAQAB
                  -----END PUBLIC KEY-----
            jwt_header: "Authorization"
            jwt_url_parameter: null
            cookieName: "Cookie"
            cookieHeaderName: "jwt_token"

and I can access it like this: String signingKey = settings.get("signing_key");
When I try to validate a JWT token using that public key it throws a InvalidKeyException.
However if I hardcode the string in my code like this, it works!
String signingKey = "-----BEGIN PUBLIC KEY-----\n" +
                    "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApJubKdzjmxriryviTEPN\n" +
                    "85qX8SzcDbseBjJXJzrt3Xn0mk7+7ZxWDnB5Qh/TvZoHGOcaVeoRIzBi1AdX20az\n" +
                    "x7oAzfMLI48sDEptwJgd87Mg6UmvXlPOkvRypUSP8pFrOUg+aQ75qRsQkXBBWMIO\n" +
                    "qBZiDXVrMHY1+Q1LOJR1aWFjIlL1WNZecTNJ9UfPhjxW7WJRmI3/EXPbD/OEeC7J\n" +
                    "mD/nifofYUQUavggcirKI0KM17ENLdyZy3aWfpKOXqZJByfbp5AXmWoWcNZqsiHy\n" +
                    "KL/sK/nmX86jwKRHvIOQv9IBlPCNSxNr6IQox/BHqZssvY2J65UHOaTJ408x7IQT\n" +
                    "FQIDAQAB\n" +
                    "-----END PUBLIC KEY-----";

How do I make sure the yaml config behaves the same way as the hardcoded one?

A:

Fairly sure using the ">" in YAML will get you a bunch of lines concatenated with spaces instead of the line feed, you might want to print out the key you obtain to see what you actually get.
If that is the case you can apply a replaceAll to get back the result that you expect.
http://yaml.org/spec/1.2/spec.html#id2760844

