Я добавляю из ресурсов приложения. Вот кусок кода:
trustStreamForTsp = context.getResources().openRawResource(R.raw.root);
loadCert(trustStreamForTsp);
Сам метод loadCert:
private void loadCert(InputStream trustStream) throws Exception {
try {
final CertificateFactory factory = CertificateFactory.getInstance("X.509");
trustCerts.add((X509Certificate) factory.generateCertificate(trustStream));
} finally {
if (trustStream != null) {
try {
trustStream.close();
} catch (IOException e) {
;
}
} // if
}
}
UPD: Добавился мой сертификат в список, но цепочка все равно не хочет строиться(мой сертификат предпоследний):
2020-07-21 15:08:29.898 28264-28321/com.example.testlake D/JCP: ru.CryptoPro.ssl.android.cl_66.a ::
%% adding as trusted certificates %%
--------
Subject: CN=CryptoPro VPN CA, O=Crypto-Pro Ltd., L=Moscow, C=RU, EMAILADDRESS=vpnca@cryptopro.ru
Serial number: 3ddff7917a4f67814e346f510129da7d
Valid from Mon Sep 19 10:44:26 GMT+02:00 2011 until Sat Sep 19 09:54:24 GMT+02:00 2026
--------
Subject: CN="Тестовый УЦ ООО \"КРИПТО-ПРО\"", O="ООО \"КРИПТО-ПРО\"", L=Москва, ST=г. Москва, C=RU, STREET=ул. Сущёвский вал д. 18, OID.1.2.643.3.131.1.1=#120C303031323334353637383930, OID.1.2.643.100.1=#120D31323334353637383930313233
Serial number: 3b208ae5fd46688649a050faafa88393
Valid from Wed Sep 12 12:19:30 GMT+02:00 2018 until Tue Sep 12 12:28:55 GMT+02:00 2023
--------
Subject: CN=Минкомсвязь России, OID.1.2.643.3.131.1.1=#120C303037373130343734333735, OID.1.2.643.100.1=#120D31303437373032303236373031, O=Минкомсвязь России, STREET="улица Тверская, дом 7", L=г. Москва, ST=77 Москва, C=RU, EMAILADDRESS=dit@minsvyaz.ru
Serial number: 4e6d478b26f27d657f768e025ce3d393
Valid from Fri Jul 06 14:18:06 GMT+02:00 2018 until Tue Jul 01 14:18:06 GMT+02:00 2036
--------
Subject: CN=CRYPTO-PRO Test Center 2, O=CRYPTO-PRO LLC, L=Moscow, C=RU, EMAILADDRESS=support@cryptopro.ru
Serial number: 37418882f539a5924ad44e3de002ea3c
Valid from Mon May 27 09:24:26 GMT+02:00 2019 until Sun May 26 09:34:05 GMT+02:00 2024
--------
Subject: CN=УЦ KPИПTO-ПPO, O=ООО КРИПТО-ПРО, L=Москва, C=RU, EMAILADDRESS=cpca@cryptopro.ru
Serial number: 3d755a8f8468798f4fa0c0218929d594
Valid from Fri Nov 11 10:11:11 GMT+02:00 2011 until Sun Nov 10 09:21:11 GMT+02:00 2041
--------
Subject: CN=CryptoPro VPN CA, O=Crypto-Pro Ltd., L=Moscow, C=RU, EMAILADDRESS=vpnca@cryptopro.ru
Serial number: 6e4e5ed4a6de41ba4b1eebc491f4e22e
Valid from Tue May 05 14:31:05 GMT+02:00 2015 until Sun May 05 14:41:03 GMT+02:00 2030
--------
Subject: CN=CryptoPro GOST Root CA, O="LLC \"Crypto-Pro\"", L=Moscow, ST=Moscow, C=RU, OID.1.2.643.3.131.1.1=#120C303037373137313037393931, OID.1.2.643.100.1=#120D31303337373030303835343434
Serial number: 4056ed0099a9d6af49c9ff98b9c70e70
Valid from Thu Nov 15 16:14:09 GMT+02:00 2018 until Tue Nov 15 16:14:09 GMT+02:00 2033
--------
Subject: CN=УЦ КРИПТО-ПРО (ГОСТ 2012), O="ООО \"КРИПТО-ПРО\"", L=Москва, ST=Москва, C=RU, EMAILADDRESS=cpca@cryptopro.ru
Serial number: 1e3fbf60031a9579540ca4145db0c179c
Valid from Fri Aug 03 16:49:15 GMT+02:00 2018 until Wed Aug 03 16:49:15 GMT+02:00 2033
--------
Subject: CN=УЦ KPИПTO-ПPO, O=ООО КРИПТО-ПРО, L=Москва, C=RU, EMAILADDRESS=cpca@cryptopro.ru
Serial number: 6a7c887538f2cd8b4126ff8e40c3ddba
Valid from Wed Sep 09 17:01:35 GMT+02:00 2015 until Mon Sep 09 17:01:35 GMT+02:00 2030
--------
Subject: CN=Головной удостоверяющий центр, OID.1.2.643.3.131.1.1=#120C303037373130343734333735, OID.1.2.643.100.1=#120D31303437373032303236373031, O=Минкомсвязь России, STREET="125375 г. Москва, ул. Тверская, д. 7", L=Москва, ST=77 г. Москва, C=RU, EMAILADDRESS=dit@minsvyaz.ru
Serial number: 34681e40cb41ef33a9a0b7c876929a29
Valid from Fri Jul 20 15:31:14 GMT+02:00 2012 until Sat Jul 17 14:31:14 GMT+02:00 2027
--------
Subject: OU=nGate MC Certificate Authority, O=whitelake, C=RU, CN=nGate Management Console
Serial number: -504dd3334460d11da29f484
Valid from Tue Apr 14 01:06:07 GMT+02:00 2020 until Fri Apr 14 01:06:07 GMT+02:00 2023
--------
Subject: CN="ООО \"КРИПТО-ПРО\"", O="ООО \"КРИПТО-ПРО\"", L=Москва, ST=г. Москва, C=RU, EMAILADDRESS=qca@cryptopro.ru, STREET=ул. Сущёвский вал д. 18, OID.1.2.643.3.131.1.1=#120C303037373137313037393931, OID.1.2.643.100.1=#120D31303337373030303835343434
Serial number: 3e6559a570ee6fbb419c7c05ae13c293
Valid from Wed Feb 04 10:33:34 GMT+02:00
Ошибка выглядит следующим образом:
2020-07-21 15:08:33.338 28264-28321/com.example.testlake W/JCP: ru.CryptoPro.ssl.android.cl_62.a :: unable to find valid certification path to requested target
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Отредактировано пользователем 21 июля 2020 г. 16:11:35(UTC)
| Причина: Не указана