title: How do I decode a DER encoded string in Java?
body: <p>I'm trying to read a custom extension from a digital certificate. I know the value is a GeneralString encoded in DER. Is there an easy way to correctly decode it and get a Java String? I tried the following, but 's' includes some of the encoding metadata as junk characters at the start of the string.</p>
  
  <pre><code>byte[] ext = cert.getExtensionValue("1.2.3.4");
  String s= new String(ext);
  System.out.println(s);
  </code></pre>
  
  <p>Is there a quick and easy way to do this? Or do I really need to use some full fledged ASN.1 library?</p>
  
  <p>Thanks!</p>