Sometimes u need check certificate valid date on server. U can do this in java simple:
FileInputStream certFileInputStream = new FileInputStream("/home/vasif/handysofts.com.crt"); CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate)certFactory.generateCertificate(certFileInputStream); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); String validEndDate = sdf.format(cert.getNotAfter()); String validBeginDate = sdf.format(cert.getNotBefore()); System.out.println("Valid From "+" "+validBeginDate+" to "+validEndDate);
No comments:
Post a Comment