title: Base64 decode error Last unit does not have enough valid bits
body: <p>I have a certificate sent to me by my vendor in a <code>.p7b</code> file. I need to extract the certificates from it. So I run this on my cmd:</p>
  <pre><code>openssl pkcs7 -inform DER -outform PEM -in in.p7b -print_certs &gt; cer_bundle.cer
  </code></pre>
  <p>I open up <code>cer_bundle.cer</code> and see three certificates. First two seem fine. The final certificate when put thru <code>Base64.getDecoder().decode(myCert)</code> throws up an error like:</p>
  <pre><code>java.lang.IllegalArgumentException: Last unit does not have enough valid bits\n\tat 
  java.util.Base64$Decoder.decode0(Base64.java:734)\n\tat 
  java.util.Base64$Decoder.decode(Base64.java:526)\n\tat 
  java.util.Base64$Decoder.decode(Base64.java:549)\n\t
  ...
  </code></pre>
  <p>I then take contents of the cert and do this on my terminal</p>
  <pre><code>CERT=MIIFDj...
  base64 --decode &lt;&lt;&lt; $CERT
  </code></pre>
  <p>and I see an output on my console with no errors.</p>
  <p>What's going on in java's Base64 decoder?</p>