I have to open cert file in my Java class. Certyficates are encoded by DER algorithm. How can i decode this file ?
I upload certyficate to my servlet, this way
InputStream in = getResourceAsStream("/certyficate.cer");
BufferedReader br = new BufferedReader(new InputStreamReader(in))
now i have to decode this file, how can i do that ?
Now i have have trouble with, get.Instance()

i used it exactly how it is in documentation, but i have an error like in this screenshot
how can i fix that ?
Given your InputStream in containing the certificate,
 you can decode the certificate
through java.security.cert.CertificateFactory. DER and PEM encodings are supported.
Imports you will need:
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
To decode the certificate:
try {
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    X509Certificate cert = (X509Certificate) cf.generateCertificate(in);
} catch (CertificateException e) {
    // handle failure to decode certificate
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With