You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static String serverCert= "certs/spidrserver.pem";
public static String intCert= "certs/spidrinter.pem";
public static String rootCert= "certs/spidrroot.pem";
static byte[] certDataServer = Base64.decodeBase64(serverCert.getBytes());
static byte[] certDataInt = Base64.decodeBase64(intCert.getBytes());
static byte[] certDataRoot = Base64.decodeBase64(rootCert.getBytes());
static File certFile = new File(serverCert);
public static void isFileExist(){
if (certFile.exists()){
System.out.println("Certificate founded!");
}else {
System.out.println("Certificate NOT FOUND!");
}
}
public static void main(String[] args) throws OcspException {
isFileExist();
X509Certificate certificate = createCert(certDataInt);
X509Certificate issuer = createCert(certDataRoot);
// Create OCSP Client using builder.
OcspClient client = OcspClient.builder()
.set(OcspClient.EXCEPTION_ON_UNKNOWN, false) // Remove to trigger exception on 'UNKNOWN'.
.set(OcspClient.EXCEPTION_ON_REVOKED, false) // Remove to trigger exception on 'REVOKED'.
.build();
// Verify certificate (issuer certificate required).
// CertificateIssuer issuer1 = CertificateIssuer.generate(issuer);
CertificateResult response = client.verify(certificate, issuer);
// Prints 'GOOD', 'REVOKED' or 'UNKNOWN'.
System.out.println(response.getStatus());
}
public static X509Certificate createCert(byte[] certData){
try {
CertificateFactory cf=CertificateFactory.getInstance("X509");
X509Certificate cert=(X509Certificate)cf.generateCertificate(new ByteArrayInputStream(certData));
return cert;
}
catch ( Exception e) {
throw new RuntimeException(e);
}
}
}
`
When I try to run this code, I have encountered a "java.security.cert.CertificateException: Could not parse certificate: java.io.IOException: Empty input Exception"
Can you have any idea to solve this problem?
Thanks...
Koray
The text was updated successfully, but these errors were encountered:
Hi,
At first, your OCSP source code is excellent. I am trying to use your code, I wrote a main method to test it. My source code is at below;
`package net.klakegg.pkix.ocsp;
import org.apache.commons.codec.binary.Base64;
import sun.misc.BASE64Decoder;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
public class MainTest {
}
`
When I try to run this code, I have encountered a "java.security.cert.CertificateException: Could not parse certificate: java.io.IOException: Empty input Exception"
Can you have any idea to solve this problem?
Thanks...
Koray
The text was updated successfully, but these errors were encountered: