Giter Site home page Giter Site logo

java.lang.SecurityException: SHA-256 digest error for org/bouncycastle/operator/OperatorCreationException.class about compose-multiplatform HOT 3 OPEN

LazyIonEs avatar LazyIonEs commented on May 30, 2024
java.lang.SecurityException: SHA-256 digest error for org/bouncycastle/operator/OperatorCreationException.class

from compose-multiplatform.

Comments (3)

LazyIonEs avatar LazyIonEs commented on May 30, 2024

While I was solving the problem on my own I found this : #1675
I tried Execute packageUberJarForCurrentOS, Run with java -jar file.jar, and an error occurred. According to the operation in the article, I added

tasks.register<Zip>("repackageUberJar") {
    val packageReleaseUberJarForCurrentOS = tasks.getByName("packageReleaseUberJarForCurrentOS")
    dependsOn(packageReleaseUberJarForCurrentOS)
    val file = packageReleaseUberJarForCurrentOS.outputs.files.first()
    val output = File(file.parentFile, "${file.nameWithoutExtension}-repacked.jar")
    archiveFileName.set(output.absolutePath)
    destinationDirectory.set(file.parentFile.absoluteFile)
    exclude("META-INF/*.SF")
    exclude("META-INF/*.RSA")
    exclude("META-INF/*.DSA")
    from(project.zipTree(file))
    doLast {
        delete(file)
        output.renameTo(file)
        logger.lifecycle("The repackaged jar is written to ${archiveFile.get().asFile.canonicalPath}")
    }
}

I Execute packageUberJarForCurrentOS again, and Run with java -jar file.jar, all functions run normally, but when I want to Execute packageReleaseDistributionForCurrentOS, I found that there will still be SecurityException, so How to exclude few META-INF files for packageReleaseDistributionForCurrentOS, I think this may work for me very useful

from compose-multiplatform.

LazyIonEs avatar LazyIonEs commented on May 30, 2024

I tried again to solve this problem myself

  1. Try to execute runReleaseDistributable and an error occurs.
    image
  2. Looking at the log, I found that this jar package was copied from .gradle and filtered. I don’t know what was done in the middle.
    image
  3. Find the original jar file, execute jarsigner -verify, and it will prompt that the jar has been verified.
  4. Find the copied jar file and execute jarsigner -verify again, prompt
jarsigner: java.lang.SecurityException: SHA-256 digest error for org/bouncycastle/LICENSE.class
  1. Delete the internal META-INF/*.RSA, META-INF/*.SF, META-INF/*.DSA, META-INF/*.EC files from the copied bcpkix, bcprov, and bcutil jars.
  2. Execute zip -d file.jar 'META-INF/*.SF' 'META-INF/*.RSA' 'META-INF/*.DSA' 'META-INF/*.EC'
  3. Double-click to launch file.app
  4. The program runs normally, no errors are reported

I want to know what was filtered in step 2, and how can I delete some files under META-INF when copying?

from compose-multiplatform.

LazyIonEs avatar LazyIonEs commented on May 30, 2024

I'm very sorry. During my subsequent debugging, I found that this has nothing to do with resources. I will provide a minimal reproduction program to help troubleshoot the problem.

https://github.com/LazyIonEs/compose-multiplatform-desktop-template

In the above program, when I add in compose-desktop.pro

-keepclasseswithmembers public class MainKt {
     public static void main(java.lang.String[]);
}

-keep class org.bouncycastle.** { *; }

When executing runReleaseDistributable, an error message java.lang.SecurityException: SHA-256 digest error for org/bouncycastle/operator/OperatorCreationException.class will appear.

I think it may be because of the rule -keep class org.bouncycastle.** { *; }, but when I delete it, the rule in compose-desktop.pro is

-keepclasseswithmembers public class MainKt {
     public static void main(java.lang.String[]);
}

# -keep class org.bouncycastle.** { *; }

I executed runReleaseDistributable again, and an error message cannot create signer: no such algorithm: SHA256WITHRSA for provider BC appeared.

I don't understand why

Can you help me solve this problem?

from compose-multiplatform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.