Question

I'm trying to load the trusted certificates on a OS X/Java 7 system. According to Java's Class KeyStore, there is a KeyStore.TrustedCertificateEntry type.

The following code:

KeyStore ks = KeyStore.getInstance(KeyStore.TrustedCertificateEntry);

Produces the following error:

HttpsCiphers.java:34: error: cannot find symbol
        KeyStore ks = KeyStore.getInstance(KeyStore.TrustedCertificateEntry);
                                                   ^
  symbol:   variable TrustedCertificateEntry
  location: class KeyStore

I'm importing both KeyStore and TrustedCertificateEntry.

How does one utilize TrustedCertificateEntry or load the trusted certificate store?


$ java -version
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: OS X 10.8.5 (12F45)
      Kernel Version: Darwin 12.5.0
      ...
Was it helpful?

Solution

KeyStore.TrustedCertificateEntry was introduced in 1.5. You must be using an earlier Java, or maybe you have your own class called KeyStore.

In any case the code is nonsense. It should be KeyStore.getInstance(KeyStore.getDefaultType()), or a String argument naming an explicit keystore type.

OTHER TIPS

According to getInstance() method Javadoc (the one that accepts String), you should use it with one of the possible values:

  • jceks - The proprietary keystore implementation provided by the SunJCE provider;
  • jks - The proprietary keystore implementation provided by the SUN provider;
  • pkcs12 - The transfer syntax for personal identity information as defined in PKCS #12;

Information taken from here.

For me it sounds like you're misusing KeyStore.TrustedCertificateEntry class as it seems to be intended to be used with getEntry()/setEntry() methods.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top