Validating a certificate in java throws an exception - unable to find valid certificate path to requested target
I have a web app that requires a client to send it's certificate and the server has to validate the certificate(i.e see if the issuer is a valid issuer and present in the server's truststore). Here is the code : FileInputStream fin=new FileInputStream("C:/trustedca"); KeyStore anchors = KeyStore.getInstance("JKS","SUN"); anchors.load(fin, "server".toCharArray()); X509CertSelector target = new X509CertSelector(); FileInputStream fin1=new FileInputStream("C:/client.crt"); CertificateFactory cf=CertificateFactory.getInstance("X.509"); X509Certificate cert=null; while (fin1.available() > 0) {