Ключевое слово в защите информации
КЛЮЧЕВОЕ СЛОВО
в защите информации
Получить ГОСТ TLS-сертификат для домена (SSL-сертификат)
Добро пожаловать, Гость! Чтобы использовать все возможности Вход или Регистрация.

Уведомление

Icon
Error

2 Страницы<12
Опции
К последнему сообщению К первому непрочитанному
Offline distep2  
#11 Оставлено : 29 октября 2024 г. 20:24:35(UTC)
distep2

Статус: Участник

Группы: Участники
Зарегистрирован: 29.10.2024(UTC)
Сообщений: 10
Российская Федерация
Откуда: Екатеринбург

Сказал(а) «Спасибо»: 1 раз
Запросы отправляю в ГИИС ДМДК https://exchange.dmdk.ru/ws/v3

с GostTLSv1.2 получаю туже ошибку:

Код:

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_64 a
FINE: Master Secret:  ru.CryptoPro.JCSP.Key.MasterSecret@82da5c9
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_64 a
FINE: Client MAC write Secret:  ru.CryptoPro.JCSP.Key.GostSecretKey@e2931b1
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_64 a
FINE: Server MAC write Secret:  ru.CryptoPro.JCSP.Key.GostSecretKey@634fa039
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_64 a
FINE: Client write key:  ru.CryptoPro.JCSP.Key.GostSecretKey@a07479d
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_64 a
FINE: Server write key:  ru.CryptoPro.JCSP.Key.GostSecretKey@6fe1a8f9
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_64 a
ALL: Client write IV: 
0000: CD C6 3B 36 A9 3E 3E 21                            ..;6.>>!

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_64 a
ALL: Server write IV: 
0000: 2F 9B 3B BD 93 3D 2E 57                            /.;..=.W

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_80 a
FINER: main, WRITE: TLSv1.2 Change Cipher Spec, length = 1
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_80 a
ALL: [Raw write]: length =  6 
0000: 14 03 03 00 01 01                                  ......

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_7 <init>
FINER: Fixed IV = CD C6 3B 36 A9 3E 3E 21
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_48 f
FINE: *** Finished
verify_data:  { 128, 39, 203, 96, 34, 49, 188, 229, 154, 85, 219, 182, 89, 51, 179, 252, 200, 179, 100, 216, 141, 188, 224, 191, 190, 247, 217, 38, 5, 242, 141, 73 }
***

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_80 a
ALL: [write] GOST hashes: len =  36 
0000: 14 00 00 20 80 27 CB 60   22 31 BC E5 9A 55 DB B6  ... .'.`"1...U..
0010: 59 33 B3 FC C8 B3 64 D8   8D BC E0 BF BE F7 D9 26  Y3....d........&
0020: 05 F2 8D 49                                        ...I

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_79 f
FINER: Update MAC keys...
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_79 f
FINER: seq_num = 0
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_80 a
FINE: MAC computed: 3E 71 6D 74 55 29 97 71 7A 38 0E AB E7 67 87 0F
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_7 a
FINER: Updating cipher keys...
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_7 a
FINER: seq_num = 0
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_7 a
FINER: New IV = CD C6 3B 36 A9 3E 3E 21
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_7 a
FINE: Begin encrypt... 
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_7 a
ALL: Plaintext before ENCRYPTION: len =  52 
0000: 14 00 00 20 80 27 CB 60   22 31 BC E5 9A 55 DB B6  ... .'.`"1...U..
0010: 59 33 B3 FC C8 B3 64 D8   8D BC E0 BF BE F7 D9 26  Y3....d........&
0020: 05 F2 8D 49 3E 71 6D 74   55 29 97 71 7A 38 0E AB  ...I>qmtU).qz8..
0030: E7 67 87 0F                                        .g..

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_7 a
FINE: Encrypted... 
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_80 a
ALL: [Raw write]: length =  57 
0000: 16 03 03 00 34 BC 4A EC   47 CD 39 64 04 53 BA 6C  ....4.J.G.9d.S.l
0010: BE 4A 5B 11 00 E6 E9 F1   4E 12 CE A2 42 54 EC B7  .J[.....N...BT..
0020: D6 23 92 8C D1 C3 66 DA   E9 85 43 FF 12 06 49 6D  .#....f...C...Im
0030: 02 1F 38 90 FB 87 B7 9D   F3                       ..8......

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_69 a
ALL: [Raw read]: length =  5 
0000: 15 03 03 00 02                                     .....

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_69 a
ALL: [Raw read]: length =  2 
0000: 02 28                                              .(

Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.cl_69 b
FINER: main, READ: TLSv1.2 Alert, length = 2
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.SSLSocketImpl b
FINE: main, RECV TLSv1.2 ALERT:  fatal,  description = handshake_failure
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.SSLSessionImpl invalidate
FINE: %% Invalidated: {0} [Session-1, TLS_GOSTR341112_256_WITH_KUZNYECHIK_CTR_OMAC]
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.SSLSocketImpl i
FINE: main called closeSocket()
Oct 29, 2024 5:12:50 PM ru.CryptoPro.ssl.SSLSocketImpl a
WARNING: main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
[2024-10-29 22:12:50,972] WARN  [SSLLogger] [main] [] main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

	at ru.CryptoPro.ssl.Alerts.getSSLException(Unknown Source)
	at ru.CryptoPro.ssl.Alerts.getSSLException(Unknown Source)
	at ru.CryptoPro.ssl.SSLSocketImpl.b(Unknown Source)
	at ru.CryptoPro.ssl.SSLSocketImpl.a(Unknown Source)
	at ru.CryptoPro.ssl.SSLSocketImpl.o(Unknown Source)
	at ru.CryptoPro.ssl.SSLSocketImpl.b(Unknown Source)
	at ru.CryptoPro.ssl.SSLSocketImpl.startHandshake(Unknown Source)
	at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:589)
	at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:187)
	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:142)
	at ru.yandex.market.integration.dmdk.https.HttpsConnectionTest.check(HttpsConnectionTest.java:154)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)



Offline Санчир Момолдаев  
#12 Оставлено : 30 октября 2024 г. 3:33:57(UTC)
Санчир Момолдаев

Статус: Сотрудник

Группы: Модератор, Участники
Зарегистрирован: 03.12.2018(UTC)
Сообщений: 1,190
Российская Федерация

Сказал(а) «Спасибо»: 100 раз
Поблагодарили: 272 раз в 253 постах
по этому адресу 2х сторонний тлс.
вы создавали KeyManager?
Техническую поддержку оказываем тут
Наша база знаний
Offline distep2  
#13 Оставлено : 30 октября 2024 г. 9:11:52(UTC)
distep2

Статус: Участник

Группы: Участники
Зарегистрирован: 29.10.2024(UTC)
Сообщений: 10
Российская Федерация
Откуда: Екатеринбург

Сказал(а) «Спасибо»: 1 раз
приватный ключ не загружал в хранилище точно. Как его правильно добавить? Не находил примеров. Вот весь код:

Код:

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class HttpsConnectionTest extends AbstractFunctionalTest {

    final String keystoreName = JCP.HD_STORE_NAME;
    final String trustStoreName = "JKS"; //"HDImageStore";
    final String trustStorePassword = "root";
    final String trustStorePath = "trust.store.jks";
    final String keystorePath = "key.store";
    final String keystorePassword = "1";
    final String[] rootCertPaths = new String[] {"tls/GoznakRootCA2.pem", "tls/GoznakRootCA3.pem"};
    final String myCertPath = "tls/myCert.cer";

    final String HEALTH_REQUEST = "requests/health_request.xml";

    @BeforeAll
    public void beforeAll() throws Exception {

        Security.addProvider(new JCSP());
        Security.addProvider(new JCP());
        Security.addProvider(new CryptoProvider());
        Security.addProvider(new RevCheck());
        Security.addProvider(new Provider());

        System.setProperty("com.sun.security.enableCRLDP", "true");
        System.setProperty("com.ibm.security.enableCRLDP", "true");
        System.setProperty("disable_default_context", "true");

        Security.setProperty("ssl.SocketFactory.provider", "ru.CryptoPro.ssl.SSLSocketFactoryImpl");
        Security.setProperty("ssl.ServerSocketFactory.provider", "ru.CryptoPro.ssl.SSLServerSocketFactoryImpl");
        Security.setProperty("ssl.KeyManagerFactory.algorithm", "GostX509");
        Security.setProperty("ssl.TrustManagerFactory.algorithm", "GostX509");

        Files.deleteIfExists(Paths.get(keystorePath));
        Files.createFile(Paths.get(keystorePath));

        //Запись сертификата в хранилище
        addCert(myCertPath, keystoreName, keystorePassword, keystorePath, "cert");

        Files.deleteIfExists(Paths.get(trustStorePath));
        Files.createFile(Paths.get(trustStorePath));

        KeyStore rootks = KeyStore.getInstance(trustStoreName);
        rootks.load(null, null);
        int i = 1;
        //Запись сертификата в хранилище
        for (String rootCertPath : rootCertPaths) {
            Certificate rootCert = loadCertificate(rootCertPath);
            rootks.setCertificateEntry("root" + i++, rootCert);
        }

        OutputStream os = Files.newOutputStream(Paths.get(trustStorePath));
        rootks.store(os, trustStorePassword.toCharArray());

        System.out.println(HDImageStore.getDir());
    }


    @Test
    public void check() throws Exception {
        String urlPath = "https://exchange.dmdk.ru/ws/v3";
        URL url = new URL(urlPath);

        KeyStore keyStore = KeyStore.getInstance(keystoreName, "JCP");
        keyStore.load(Files.newInputStream(Paths.get(keystorePath)), keystorePassword.toCharArray());

        KeyManagerFactory kmf = KeyManagerFactory.getInstance("GostX509", "JTLS");
        kmf.init(keyStore, "1".toCharArray());

        KeyStore trustedKeyStore = KeyStore.getInstance(trustStoreName);
        trustedKeyStore.load(Files.newInputStream(Paths.get(trustStorePath)), trustStorePassword.toCharArray());

        TrustManagerFactory tmf = TrustManagerFactory.getInstance("GostX509", "JTLS");
        tmf.init(trustedKeyStore);

        SSLContext sslContext = SSLContext.getInstance(Provider.ALGORITHM_12, "JTLS");
        sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

        SSLSocketFactory socketFactory = sslContext.getSocketFactory();

        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
        connection.setSSLSocketFactory(socketFactory);

        connection.connect();
        print_content(connection, null);

        connection.disconnect();
        System.out.println("OK");

    }

    public KeyStore addCert(String certPath, String keystoreName,
        String keystorePass,
        String keystorePath, String alias) throws Exception {
        final CertificateFactory cf = CertificateFactory.getInstance("X.509");

        final Certificate rootCert = cf.generateCertificate(getSystemResourceAsStream(certPath));

        final KeyStore ks = KeyStore.getInstance(keystoreName, "JCP");
        char[] KeyStorePass = null;
        if (!"null".equalsIgnoreCase(keystorePass)) {
            KeyStorePass = keystorePass.toCharArray();
        }
        InputStream is = null;
        if (!"null".equalsIgnoreCase(keystorePath)) {
            is = new FileInputStream(keystorePath);
        }
        ks.load(is, KeyStorePass);

        ks.setCertificateEntry(alias, rootCert);

        OutputStream os = null;
        if (!"null".equalsIgnoreCase(keystorePath)) {
            os = new FileOutputStream(keystorePath);
        }
        ks.store(os, KeyStorePass);
        Logger.getLogger("LOGGER").info(
            "Recording of a Certificate named \"" + alias + "\" to " +
                keystoreName + " is completed.");
        return ks;
    }

    private Certificate loadCertificate(String certificateFile) throws Exception{
        try (InputStream inputStream = getSystemResourceAsStream(certificateFile)) {
            return (Certificate) CertificateFactory.getInstance("X.509").generateCertificate(inputStream);
        }
    }
}
Offline Санчир Момолдаев  
#14 Оставлено : 30 октября 2024 г. 9:16:50(UTC)
Санчир Момолдаев

Статус: Сотрудник

Группы: Модератор, Участники
Зарегистрирован: 03.12.2018(UTC)
Сообщений: 1,190
Российская Федерация

Сказал(а) «Спасибо»: 100 раз
Поблагодарили: 272 раз в 253 постах
посмотрите пример тут https://github.com/msham...rt/spring/example/config
Техническую поддержку оказываем тут
Наша база знаний
RSS Лента  Atom Лента
Пользователи, просматривающие эту тему
Guest
2 Страницы<12
Быстрый переход  
Вы не можете создавать новые темы в этом форуме.
Вы не можете отвечать в этом форуме.
Вы не можете удалять Ваши сообщения в этом форуме.
Вы не можете редактировать Ваши сообщения в этом форуме.
Вы не можете создавать опросы в этом форуме.
Вы не можете голосовать в этом форуме.