JDK-6219491 : CertStore.getInstance(String,CertStoreParameters,String) throws NoSuchAlgorithmE
  • Type: Bug
  • Component: security-libs
  • Sub-Component: java.security
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-01-20
  • Updated: 2010-04-02
  • Resolved: 2005-02-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u3Fixed 6 betaFixed
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
I have created my own CertStore provider that works in all previous J2SE 1.4.x versions. Now when I try to get my CertStore instance using the below code in Java 5, then it throws a java.security.NoSuchAlgorithmException saying "Error constructing implementation (algorithm: MY, provider: assembla, class: se.assembla.jce.provider.ms.MSCertStoreMYJNI)":

CertStore store = CertStore.getInstance("MY", null, "assembla");


However, if I use the following code, then everything works fine:

CertStore store = CertStore.getInstance("MY", new CollectionCertStoreParameters(), "assembla");


The Java 5 Javadoc API specification clearly says the second parameter (CertStoreParameters)  can be null:
Parameters:
    type - the requested CertStore type
    params - the initialization parameters (may be null)
    provider - the name of the provider


Please let me now if you need more information to resolve this.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a simple CertStore provider.
2. Execute the following code (replace the provider and type name with your own):
CertStore store = CertStore.getInstance(<type>, null, <provider>);

You can also reproduce it by:
1. Download the Assembla JCE Provider from https://download.assembla.se/download/index.jsp
2. Execute the following code:
java.security.Security.addProvider(new se.assembla.jce.provider.ms.MSProvider());
java.security.cert.CertStore store = java.security.cert.CertStore.getInstance("MY", null, "assembla");


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The CertStore instance.
ACTUAL -
It throws a java.security.NoSuchAlgorithmException.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: MY, provider: assembla, class: se.assembla.jce.provider.ms.MSCertStoreMYJNI)
 	at java.security.Provider$Service.newInstance(Provider.java:1099)
 	at sun.security.jca.GetInstance.getInstance(GetInstance.java:227)
 	at sun.security.jca.GetInstance.getInstance(GetInstance.java:196)
 	at java.security.cert.CertStore.getInstance(CertStore.java:238)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
// This require that you have downloaded the  Assembla JCE Provider from:
// https://download.assembla.se/download/index.jsp

import  java.security.Security;
import se.assembla.jce.provider.ms.*;
import java.security.cert.CertStore;

public class FooBar
{
    int main(String[] args)
    {
        Security.addProvider(new MSProvider());
        CertStore store = CertStore.getInstance("MY", null, "assembla");
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Replace the the null parameter (i.e. the second parameter) in method call CertStore.getInstance(String,CertStoreParameters,String) with a CollectionCertStoreParameters object:

CertStore store = CertStore.getInstance("MY", new CollectionCertStoreParameters(), "assembla");
###@###.### 2005-1-20 12:40:15 GMT

Comments
EVALUATION Provider.Service.newInstance does not allow a null constructor parameter. ###@###.### 2005-1-21 23:57:39 GMT
21-01-2005