473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to read SSL certificates?

I have several web servers with SSL certificates installed.
My plan is to write a java program which will grab the certs
via ftp, then read (parse) the certificate information.
Ultimately what I want is the expiration date. I found an
example of printing a cert (listed below), but get unresolved
symbol errors when compiling. I thought I needed the Java
Cryptography Extension (JCE), so I downloaded and installed
that, but still get the error. What do I need to do in order
to parse a Verisign certificate, in either .cer or .crt format?

-Thanks
import java.security.cert.*;
import java.io.*;

public class PrintCert {
public static void main(String args[]) {
try {
FileInputStream fr = new FileInputStream("sdo.cer");
X509Certificate c = X509Certificate.getInstance(fr);
System.out.println("Read in the following certificate:");
System.out.println("\tCertificate for: " + c.getSubjectDN());
System.out.println("\tCertificate issued by: " + c.getIssuerDN());
System.out.println("\tThe certificate is valid from " +
c.getNotBefore() + " to " + c.getNotAfter());
System.out.println("\tCertificate SN# " + c.getSerialNumber());
System.out.println("\tGenerated with " + c.getSigAlgName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
Jul 17 '05 #1
0 2083

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Next | last post by:
Hello, I sure could use someone's help : ) I need to authenticate users and securely upload files from laptops on the internet ( not on the same domain as server ) to a server on my domain....
0
by: dinoo | last post by:
Can some body help me out? I am trying to use client certificates in a Webservice. But some how i am not able to make it. I went through the msdn resources but i think some one needs to help me...
2
by: Larry David | last post by:
Hi, This is one of those posts where not only do I not know the answer, I don't fully understand the *question* that I should be asking... but I'll try my best: I've designed a web site which...
5
by: | last post by:
Hi all, HttpWebRequest, and SoapHttpClientProtocol both expose a ClientCertificates property, which can hold multiple client certificates, but on the service side, it can only receive one client...
1
by: rds | last post by:
We are developing a smart client application which consumes web services. The web services are being secured with X509 certificates. During the development/testing phase we have been using the X509...
2
by: Rune Nergard | last post by:
I have tried to use the System.Security.Cryptography.Xml.SignedXml class to sign an Xml message with Xml-DSIG and using an Enveloped signature type and the sha1RSA algorithm. Everything works fine...
0
by: Schweizer Karo | last post by:
hallo ng. i have a problem on a client. when i try to use a web-services call, i get the exception: "The underlying connection was closed: Could not establish secure channel for SSL/TLS." ...
2
by: b.fokke | last post by:
I'd like to connect to a webservice using TLS/SSL. I have two separate client certificates: 1. A certificate for digital verification 2. A certificate for encryption. When I use the first one...
5
by: GaryDean | last post by:
I have to write an asp.net app that uses a web service requiring x.509 certificates. Are there any good docs on how to do this both in code and on the server. Most of the stuff I'm finding...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.