Skip to content

Commit

Permalink
Merge pull request #547 from martenrebane/MOPPAND-1358-2
Browse files Browse the repository at this point in the history
Updated libdigidocpp
  • Loading branch information
Counter178 authored Oct 30, 2024
2 parents a0e4d39 + 6ad0268 commit 4a74e42
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
Binary file modified common-lib/libs/libdigidocpp.jar
Binary file not shown.
Binary file modified sign-lib/src/debug/jniLibs/arm64-v8a/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/debug/jniLibs/armeabi-v7a/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/debug/jniLibs/x86_64/libdigidoc_java.so
Binary file not shown.
30 changes: 18 additions & 12 deletions sign-lib/src/main/java/ee/ria/DigiDoc/sign/SignedContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private static String toHexString(byte[] bytes) {
Splitter.fixedLength(2).split(Hex.toHexString(bytes))).trim();
}

private static Signature signature(ee.ria.libdigidocpp.Signature signature, boolean isTimestamp) {
private static Signature signature(ee.ria.libdigidocpp.Signature signature, boolean isTimestamp) throws CertificateException, IOException {
String id = signature.id();
String name = isTimestamp ? timestampName(signature) : signatureName(signature);
Instant createdAt = Instant.parse(signature.trustedSigningTime());
Expand All @@ -421,9 +421,13 @@ private static Signature signature(ee.ria.libdigidocpp.Signature signature, bool
String signersCertificateIssuer = "";
X509Certificate signingCertificate = null;

if (x509Certificate(signature.signingCertificateDer()) != null) {
signersCertificateIssuer = getX509CertificateIssuer(x509Certificate(signature.signingCertificateDer()));
signingCertificate = x509Certificate(signature.signingCertificateDer());
byte[] encodedSigningCertificate = signature.signingCertificate().getEncoded();
byte[] encodedTimestampCertificate = signature.TimeStampCertificate().getEncoded();
byte[] encodedOcspCertificate = signature.OCSPCertificate().getEncoded();

if (x509Certificate(encodedSigningCertificate) != null) {
signersCertificateIssuer = getX509CertificateIssuer(x509Certificate(encodedSigningCertificate));
signingCertificate = x509Certificate(encodedSigningCertificate);
}
String signatureMethod = signature.signatureMethod();
String signatureFormat = signature.profile();
Expand All @@ -433,17 +437,17 @@ private static Signature signature(ee.ria.libdigidocpp.Signature signature, bool

String tsCertificateIssuer = "";
X509Certificate tsCertificate = null;
if (signature.TimeStampCertificateDer() != null && signature.TimeStampCertificateDer().length > 0) {
tsCertificate = x509Certificate(signature.TimeStampCertificateDer());
if (encodedTimestampCertificate != null && encodedTimestampCertificate.length > 0) {
tsCertificate = x509Certificate(encodedTimestampCertificate);
if (tsCertificate != null) {
tsCertificateIssuer = getX509CertificateIssuer(tsCertificate);
}
}

String ocspCertificateIssuer = "";
X509Certificate ocspCertificate = null;
if (signature.OCSPCertificateDer() != null && signature.OCSPCertificateDer().length > 0) {
ocspCertificate = x509Certificate(signature.OCSPCertificateDer());
if (encodedOcspCertificate != null && encodedOcspCertificate.length > 0) {
ocspCertificate = x509Certificate(encodedOcspCertificate);
if (ocspCertificate != null) {
ocspCertificateIssuer = getX509CertificateIssuer(ocspCertificate);
}
Expand Down Expand Up @@ -490,9 +494,10 @@ private static String getFormattedDateTime(String dateTimeString, boolean isUTC)
private static String signatureName(ee.ria.libdigidocpp.Signature signature) {
String commonName;
try {
commonName = Certificate.create(ByteString.of(signature.signingCertificateDer()))
byte[] encodedSigningCertificate = signature.signingCertificate().getEncoded();
commonName = Certificate.create(ByteString.of(encodedSigningCertificate))
.friendlyName();
} catch (IOException e) {
} catch (IOException | CertificateException e) {
Timber.log(Log.ERROR, e, "Can't parse certificate to get CN");
commonName = null;
}
Expand All @@ -502,9 +507,10 @@ private static String signatureName(ee.ria.libdigidocpp.Signature signature) {
private static String timestampName(ee.ria.libdigidocpp.Signature signature) {
String commonName;
try {
commonName = Certificate.create(ByteString.of(signature.TimeStampCertificateDer()))
byte[] encodedTimestampCertificate = signature.TimeStampCertificate().getEncoded();
commonName = Certificate.create(ByteString.of(encodedTimestampCertificate))
.friendlyName();
} catch (IOException e) {
} catch (IOException | CertificateException e) {
Timber.log(Log.ERROR, e, "Can't parse certificate to get CN");
commonName = null;
}
Expand Down
Binary file modified sign-lib/src/main/jniLibs/arm64-v8a/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/main/jniLibs/armeabi-v7a/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/main/jniLibs/x86_64/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/main/res/raw/schema.zip
Binary file not shown.

0 comments on commit 4a74e42

Please sign in to comment.