Здравствуйте. Проблема похожая с описанной в теме
https://www.cryptopro.ru....aspx?g=posts&t=7701Но там так к решению и не пришли. Имеем код :
Код:
public void callSSLConnection() throws Exception {
SSLSocketFactory sslFactory = createSSLSocketFactory();
System.out.println(sslFactory);
URL url = new URL("https://ssl.test.url");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setSSLSocketFactory(sslFactory);
....
}
private static SSLSocketFactory createSSLSocketFactory() {
SSLSocketFactory sslFactory;
try {
KeyStore trustSt = KeyStore.getInstance("HDImageStore", "JCP");
trustSt.load(new FileInputStream(new File("/test_crypto_store")),
"password".toCharArray());
if (!trustSt.aliases().hasMoreElements()) {
throw new RuntimeException("Empty keystore");
} else {
Enumeration<String> enumalias = trustSt.aliases();
while (enumalias.hasMoreElements()) {
System.out.println(enumalias.nextElement());
}
}
TrustManagerFactory tmf =
TrustManagerFactory.getInstance("GostX509");
tmf.init(trustSt);
SSLContext ctx = SSLContext.getInstance("GostTLS");
ctx.init(null, tmf.getTrustManagers(), null);
sslFactory = ctx.getSocketFactory();
} catch (Exception e) {
throw new RuntimeException("During prepare ssl factory ", e);
}
return sslFactory;
}
На connection.getOutputStream() получаем ошибку :
javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at ru.CryptoPro.ssl.C.a(Unknown Source)
at ru.CryptoPro.ssl.am.a(Unknown Source)
at ru.CryptoPro.ssl.am.a(Unknown Source)
at ru.CryptoPro.ssl.am.a(Unknown Source)
at ru.CryptoPro.ssl.am.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)[:1.7.0_72]
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)[:1.7.0_72]
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1091)[:1.7.0_72]
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)[:1.7.0_72]
at ru.test.RouteHelper.callSSLConnection(RouteHelper.java:43)[213:ru.citc.test.cronos-test:1.0.0.SNAPSHOT]
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_72]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_72]
at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:407)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:278)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:251)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:166)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:67)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:103)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:113)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:157)[172:org.apache.camel.camel-core:2.13.2]
at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:68)[172:org.apache.camel.camel-core:2.13.2]
at java.util.TimerThread.mainLoop(Timer.java:555)[:1.7.0_72]
at java.util.TimerThread.run(Timer.java:505)[:1.7.0_72]
Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at ru.CryptoPro.ssl.w.<init>(Unknown Source)
at ru.CryptoPro.ssl.g.b(Unknown Source)
at ru.CryptoPro.ssl.g.checkServerTrusted(Unknown Source)
at ru.CryptoPro.ssl.x.checkServerTrusted(Unknown Source)
at ru.CryptoPro.ssl.ao.a(Unknown Source)
at ru.CryptoPro.ssl.ao.a(Unknown Source)
at ru.CryptoPro.ssl.f.o(Unknown Source)
at ru.CryptoPro.ssl.f.a(Unknown Source)
at ru.CryptoPro.ssl.am.a(Unknown Source)
at ru.CryptoPro.ssl.am.i(Unknown Source)
... 27 more
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)[:1.7.0_72]
at java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)[:1.7.0_72]
at java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:104)[:1.7.0_72]
... 37 more
Этот код работает на jcp 1.0 и java 1.6.
На тестовой машинке (jcp 2.0.38481 , jdk1.7.0_72) получаем такую ошибку. SelfTestersTests показывает что все ОК. cpSSL установлен , экспортные ограничения сняты. Кейстор скопирован с рабочей машины, алиасы видны, права есть. Урла коннекта та же что и в рабочем варианте.
Что может быть не так ?
Заранее спасибо !