Автор: Евгений Афанасьев Если у вас сертификат ключа подписи - это certificate из ks.getCertificate(alias), то попробуйте его поместить первым в списке chain, который отдаете в addSigner. Сейчас там первый - некий subscriberCert от subscriberCertPath.
Здравствуйте, в таком случае он выдает
нояб. 03, 2023 3:44:47 PM ru.CryptoPro.reprov.certpath.CertPathHelperImpl a
WARNING: ERROR
java.lang.reflect.InaccessibleObjectException: Unable to make void java.security.cert.X509CertSelector.setPathToNamesInternal(java.util.Set) accessible: module java.base does not "opens java.security.cert" to unnamed module @34340fab
at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:201)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:195)
at ru.CryptoPro.reprov.certpath.CertPathHelperImpl.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.CertPathHelper.b(Unknown Source)
at ru.CryptoPro.reprov.certpath.ForwardBuilder.b(Unknown Source)
at ru.CryptoPro.reprov.certpath.ForwardBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at ru.CryptoPro.reprov.CPCertPathBuilder.engineBuild(Unknown Source)
at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
at ru.CryptoPro.AdES.certificate.CertificateChainBuilderImpl$1CertPathBuilderWrapper.build(Unknown Source)
at ru.CryptoPro.AdES.certificate.CertificateChainBuilderImpl.build(Unknown Source)
at ru.CryptoPro.AdES.certificate.CertificateChainBuilderImpl.build(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at org.example.Main.main(Main.java:101)
нояб. 03, 2023 3:44:47 PM ru.CryptoPro.reprov.certpath.CertPathHelperImpl a
WARNING: ERROR
java.lang.reflect.InaccessibleObjectException: Unable to make void java.security.cert.X509CertSelector.setPathToNamesInternal(java.util.Set) accessible: module java.base does not "opens java.security.cert" to unnamed module @34340fab
at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:201)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:195)
at ru.CryptoPro.reprov.certpath.CertPathHelperImpl.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.CertPathHelper.b(Unknown Source)
at ru.CryptoPro.reprov.certpath.ForwardBuilder.b(Unknown Source)
at ru.CryptoPro.reprov.certpath.ForwardBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.a(Unknown Source)
at ru.CryptoPro.reprov.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at ru.CryptoPro.reprov.CPCertPathBuilder.engineBuild(Unknown Source)
at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
at ru.CryptoPro.AdES.certificate.CertificateChainBuilderImpl$1CertPathBuilderWrapper.build(Unknown Source)
at ru.CryptoPro.AdES.certificate.CertificateChainBuilderImpl.build(Unknown Source)
at ru.CryptoPro.AdES.certificate.CertificateChainBuilderImpl.build(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at org.example.Main.main(Main.java:101)
Exception in thread "main" Root certificate: serial 951fa3477c61043aadfa858627823442, subject CN=Минцифры России, OID.1.2.643.100.4=#120a37373130343734333735, OID.1.2.643.100.1=#120d31303437373032303236373031, O=Минцифры России, STREET="Пресненская набережная, дом 10, строение 2", L=г. Москва, ST=77 Москва, C=RU, EMAILADDRESS=dit@digital.gov.ru, issuer CN=Минцифры России, OID.1.2.643.100.4=#120a37373130343734333735, OID.1.2.643.100.1=#120d31303437373032303236373031, O=Минцифры России, STREET="Пресненская набережная, дом 10, строение 2", L=г. Москва, ST=77 Москва, C=RU, EMAILADDRESS=dit@digital.gov.ru, not before Sat Jan 08 20:32:39 NOVT 2022, not after Sun Jan 08 20:32:39 NOVT 2040 is untrusted; error codes: [32] 'Root certificate is in the certificate chain but not in cacerts',
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at ru.CryptoPro.XAdES.XAdESSignature.addSigner(Unknown Source)
at org.example.Main.main(Main.java:101)
Caused by: Root certificate: serial 951fa3477c61043aadfa858627823442, subject CN=Минцифры России, OID.1.2.643.100.4=#120a37373130343734333735, OID.1.2.643.100.1=#120d31303437373032303236373031, O=Минцифры России, STREET="Пресненская набережная, дом 10, строение 2", L=г. Москва, ST=77 Москва, C=RU, EMAILADDRESS=dit@digital.gov.ru, issuer CN=Минцифры России, OID.1.2.643.100.4=#120a37373130343734333735, OID.1.2.643.100.1=#120d31303437373032303236373031, O=Минцифры России, STREET="Пресненская набережная, дом 10, строение 2", L=г. Москва, ST=77 Москва, C=RU, EMAILADDRESS=dit@digital.gov.ru, not before Sat Jan 08 20:32:39 NOVT 2022, not after Sun Jan 08 20:32:39 NOVT 2040 is untrusted; error codes: [32] 'Root certificate is in the certificate chain but not in cacerts',
at ru.CryptoPro.AdES.certificate.CertificateChainBuilderImpl.validateIfRootCertificateInTrustStoreAndAddToChain(Unknown Source)
at ru.CryptoPro.AdES.certificate.CertificateChainBuilderImpl.build(Unknown Source)
at ru.CryptoPro.AdES.certificate.CertificateChainBuilderImpl.build(Unknown Source)
... 5 more
сертификат в cacerts я загрузил