title: String to PublicKey Header is too long
body: <p>I'm trying to create public key from string in this way:</p>
  
  <pre><code>byte[] keyBytes = Base64.decode(publicKeyStr.getBytes("utf-8"), Base64.DEFAULT);
  KeyFactory keyFactory = KeyFactory.getInstance("RSA");
  X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
  PublicKey publicKey = keyFactory.generatePublic(spec);
  </code></pre>
  
  <p>but </p>
  
  <pre><code>keyFactory.generatePublic(spec);
  </code></pre>
  
  <p>causes error:</p>
  
  <pre><code>java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long
  </code></pre>
  
  <p>Any other solutions and examples of creating PublicKey form String ?</p>
  
  <p>The String is:</p>
  
  <blockquote>
    <p>87Avu4YRFh25mG/5/vW7tFXORD3WYqByKZDHpcqstXKDyLYFtm8arbwXDUxcDRSJUKdZx07L1fGvExfslShssJ22nHA4bScQ7yhgrtsxNUa5NPPP/YlR9DLAnjFzf3AEbW26fLO5luQtDIDmjSvwNE6ZwAIjhRJ3HXpqw2hFMvc=AQAB</p>
  </blockquote>