如何通过使用BouncyCastle的客户端maven插件构建本地映像



我正在开发一个javaGloon项目,该项目使用面向桌面、iOS和Android的maven客户端插件构建。我现在正试图添加一个对内部java库的依赖,该库使用BouncyCastle进行加密。

通过mvn clean javafx:run执行代码会产生一个功能性应用程序,它可以很好地执行所有加密。

运行mvn clean client:build -Pios client:run -Pios在iOS上运行应用程序,但抛出java.security.NoSuchAlgorithmException: no such algorithm: AES for provider BC当我们的图书馆试图生成密码时。

我尝试过的东西:

  • <nativeImageArgs>--enable-all-security-services</nativeImageArgs>添加到客户端maven插件配置中
  • 在插件配置中将各种BouncyCastle类添加到<reflectionList>

系统信息:

  • MacOS 10.15.5
  • IntelliJ IDEA Ultimate 2020.2.2
  • java版本:
    openjdk版本"11.0.8〃;2020-07-14
    OpenJDK运行时环境GraalVM CE 20.2.0(内部版本11.0.8+10-jvmci-20.2-b03(
    OpenJDK 64位服务器VM GraalVM CE 20.2.0(构建11.0.8+10-jvmci-20.2/b03,混合模式,共享(

编辑(09/29/20(:

将AES添加到反射列表似乎让我更进一步,但我仍然遇到了一个安全错误:

[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Fatal error: javax.crypto.JceSecurity.getCodeBase(Class) is reached at runtime. This should not happen. The contents of JceSecurity.verificationResults are computed and cached at image build time. Try enabling all security services with --enable-all-security-services.
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] JavaFrameAnchor dump:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   No anchors
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] TopFrame info:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   TotalFrameSize in CodeInfoTable 32
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] VMThreads info:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   VMThread 0000000283fa1ba0  STATUS_IN_NATIVE  java.lang.Thread@0x116001028
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   VMThread 0000000283fa0f70  STATUS_IN_NATIVE  java.lang.Thread@0x115b043d0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   VMThread 0000000283fa0ea0  STATUS_IN_JAVA (safepoints disabled)  java.lang.Thread@0x115a02e10
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   VMThread 0000000283fa0dd0  STATUS_IN_NATIVE  java.lang.Thread@0x107ce30a0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] VM Thread State for current thread 0000000283fa0ea0:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   0 (8 bytes): com.oracle.svm.jni.JNIThreadLocalEnvironment.jniFunctions = (bytes) 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     0000000283fa0ea0: 00000001070a6c88
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   8 (32 bytes): com.oracle.svm.core.genscavenge.ThreadLocalAllocation.regularTLAB = (bytes) 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     0000000283fa0ea8: 0000000116600000 0000000116700000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     0000000283fa0eb8: 000000011660b960 0000000000000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   40 (8 bytes): com.oracle.svm.core.heap.NoAllocationVerifier.openVerifiers = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   48 (8 bytes): com.oracle.svm.core.jdk.IdentityHashCodeSupport.hashCodeGeneratorTL = (Object) java.util.SplittableRandom  0000000115b04600
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   56 (8 bytes): com.oracle.svm.core.snippets.ExceptionUnwind.currentException = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   64 (8 bytes): com.oracle.svm.core.thread.JavaThreads.currentThread = (Object) java.lang.Thread  0000000115a02e10
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   72 (8 bytes): com.oracle.svm.core.thread.ThreadingSupportImpl.activeTimer = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   80 (8 bytes): com.oracle.svm.jni.JNIObjectHandles.handles = (Object) com.oracle.svm.core.handles.ThreadLocalHandles  0000000115b02360
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   88 (8 bytes): com.oracle.svm.jni.JNIThreadLocalPendingException.pendingException = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   96 (8 bytes): com.oracle.svm.jni.JNIThreadLocalPinnedObjects.pinnedObjectsListHead = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   104 (8 bytes): com.oracle.svm.jni.JNIThreadOwnedMonitors.ownedMonitors = (Object) null
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   112 (8 bytes): com.oracle.svm.core.genscavenge.ThreadLocalAllocation.freeList = (Word) 0  0000000000000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   120 (8 bytes): com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.stackBoundaryTL = (Word) 1  0000000000000001
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   128 (8 bytes): com.oracle.svm.core.stack.JavaFrameAnchors.lastAnchor = (Word) 0  0000000000000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   136 (8 bytes): com.oracle.svm.core.thread.VMThreads.IsolateTL = (Word) 94598687557484880  0150150150150150
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   144 (8 bytes): com.oracle.svm.core.thread.VMThreads.OSThreadHandleTL = (Word) 6105214976  000000016be63000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   152 (8 bytes): com.oracle.svm.core.thread.VMThreads.OSThreadIdTL = (Word) 6105214976  000000016be63000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   160 (8 bytes): com.oracle.svm.core.thread.VMThreads.nextTL = (Word) 10804137424  0000000283fa0dd0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   168 (4 bytes): com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.yellowZoneStateTL = (int) -16843010  fefefefe
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   172 (4 bytes): com.oracle.svm.core.snippets.ImplicitExceptions.implicitExceptionsAreFatal = (int) 0  00000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   176 (4 bytes): com.oracle.svm.core.thread.Safepoint.safepointRequested = (int) 2147255657  7ffc8569
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   180 (4 bytes): com.oracle.svm.core.thread.ThreadingSupportImpl.currentPauseDepth = (int) 0  00000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   184 (4 bytes): com.oracle.svm.core.thread.VMThreads$ActionOnTransitionToJavaSupport.actionTL = (int) 0  00000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   188 (4 bytes): com.oracle.svm.core.thread.VMThreads$StatusSupport.safepointsDisabledTL = (int) 1  00000001
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   192 (4 bytes): com.oracle.svm.core.thread.VMThreads$StatusSupport.statusTL = (int) 1  00000001
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] VMOperation dump:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   No VMOperation in progress
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Dump Counters:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Raw Stacktrace:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62ba0: 000000011660b940 0000000000000000
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62bb0: 000000016be62be0 00000001045c4a48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62bc0: 0000000283fa0f60 000000011660b4e0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62bd0: 000000011660b4e0 000000011660b940
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62be0: 000000016be62c40 000000010569556c
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62bf0: 000000016be62c40 0000000107351138
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62c00: 0000000107d0be88 0000000107d0be48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   000000016be62c10: 0000000107351040 0000000115b11578
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Stacktrace Stage 0:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ba0 IP 00000001045ec738  FrameSize 32
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bc0 IP 00000001045c4a48  FrameSize 48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bf0 IP 000000010569556c  FrameSize 96
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c50 IP 0000000105695144  FrameSize 64
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c90 IP 00000001056990f8  FrameSize 48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62cc0 IP 000000010452012c  FrameSize 176
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62d70 IP 000000010451fbd8  FrameSize 48
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 0000000  SP 000000016be62f20 IP 0000000104fa6b2c  FrameSize 32
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f40 IP 00000001045e4a10  FrameSize 80
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f90 IP 00000001045a9c9c  FrameSize 64
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Stacktrace Stage 1:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ba0 IP 00000001045ec738  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bc0 IP 00000001045c4a48  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bf0 IP 000000010569556c  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c50 IP 0000000105695144  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c90 IP 00000001056990f8  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62cc0 IP 000000010452012c  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62d70 IP 000000010451fbd8  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62da0 IP 0000000104826860  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62e80 IP 00000001048230b4  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ee0 IP 0000000104822718  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f20 IP 0000000104fa6b2c  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f40 IP 00000001045e4a10  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f90 IP 00000001045a9c9c  com.oracle.svm.core.code.CodeInfo@0x107cbf7f8 name = image code
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Stacktrace Stage 2:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ba0 IP 00000001045ec738  [image code] com.oracle.svm.core.jdk.VMErrorSubstitutions.shutdown(VMErrorSubstitutions.java:96)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ba0 IP 00000001045ec738  [image code] com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:75)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bc0 IP 00000001045c4a48  [image code] com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:59)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bc0 IP 00000001045c4a48  [image code] com.oracle.svm.core.jdk.JceSecurityUtil.shouldNotReach(SecuritySubstitutions.java:387)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bf0 IP 000000010569556c  [image code] javax.crypto.JceSecurity.getCodeBase(JceSecurity.java:351)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62bf0 IP 000000010569556c  [image code] javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:216)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c50 IP 0000000105695144  [image code] javax.crypto.JceSecurity.getInstance(JceSecurity.java:141)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62c90 IP 00000001056990f8  [image code] javax.crypto.KeyGenerator.getInstance(KeyGenerator.java:326)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62cc0 IP 000000010452012c  [image code] com.gluonapplication.GluonApplication.securityTest(GluonApplication.java:85)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62d70 IP 000000010451fbd8  [image code] com.gluonapplication.GluonApplication.init(GluonApplication.java:45)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62da0 IP 0000000104826860  [image code] com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:824)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62e80 IP 00000001048230b4  [image code] com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62ee0 IP 0000000104822718  [image code] com.sun.javafx.application.LauncherImpl$$Lambda$6b52b8b751707d234c1e536df5c7bfccab052d36.run(Unknown Source)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f20 IP 0000000104fa6b2c  [image code] java.lang.Thread.run(Thread.java:834)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f40 IP 00000001045e4a10  [image code] com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f90 IP 00000001045a9c9c  [image code] com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   SP 000000016be62f90 IP 00000001045a9c9c  [image code] com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(IsolateEnterStub.java:0)
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] [Native image heap boundaries: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   ReadOnly Primitives: 0x106054008 .. 0x1070a4940
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   ReadOnly References: 0x1070a4978 .. 0x1076e01a8
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   ReadOnly Relocatables: 0x0 .. 0x0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   Writable Primitives: 0x107730000 .. 0x107cd4ba0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   Writable References: 0x107cd4bb8 .. 0x10838c328
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   Writable Huge: 0x0 .. 0x0
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   ReadOnly Huge: 0x0 .. 0x0]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] [Heap:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   [Young generation: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     [Eden: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]       [edenSpace:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]         aligned: 0/0 unaligned: 0/0]]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     [Survivors: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]       ]]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   [Old generation: 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     [oldFromSpace:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]       aligned: 0/0 unaligned: 0/0]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     [oldToSpace:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]       aligned: 0/0 unaligned: 0/0]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     ]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]   [Unused:
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB]     aligned: 0/0]]
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] 
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Fatal error: javax.crypto.JceSecurity.getCodeBase(Class) is reached at runtime. This should not happen. The contents of JceSecurity.verificationResults are computed and cached at image build time. Try enabling all security services with --enable-all-security-services.
[Tue Sep 29 11:01:06 EDT 2020][INFO] [SUB] Process 1187 exited with status = 99 (0x00000063) 
[Tue Sep 29 11:01:06 EDT 2020][INFO] result = true

这可能是GraalVM的已知问题,如所述

以下是我的pom文件中的插件配置:

<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>client-maven-plugin</artifactId>
<version>${client.plugin.version}</version>
<configuration>
<target>${client.target}</target>
<nativeImageArgs>-J-Djava.security.properties=java.security.overrides</nativeImageArgs>
<nativeImageArgs>--enable-all-security-services</nativeImageArgs>
<attachList>
<list>display</list>
<list>lifecycle</list>
<list>statusbar</list>
<list>storage</list>
</attachList>
<bundlesList>
<list>com.gluonapplication.views.primary</list>
<list>com.gluonapplication.views.secondary</list>
</bundlesList>
<reflectionList>
<list>com.gluonapplication.views.PrimaryPresenter</list>
<list>com.gluonapplication.views.SecondaryPresenter</list>
<list>org.bouncycastle.jcajce.provider.symmetric.AES$Mappings</list>
</reflectionList>
<mainClass>${mainClassName}</mainClass>
</configuration>
</plugin>

我为在这里共享代码而构建的示例应用程序的源代码(基于gluon插件的自动生成应用程序设置(:

public class GluonApplication extends MobileApplication {
private Provider provider;
private static final String CIPHER_ALGORITHM = "AES";
private static final String KEYPAIR_GENERATOR_ALGORITHM = "RSA";
private static final String KEY_GENERATOR_ALGORITHM = "AES";
private static final String KEY_FACTORY_ALGORITHM = "RSA";
private static final String KEY_STORE_TYPE = "PKCS12";
private static final String SIGNATURE_ALGORITHM = "SHA256withRSA";
private static final String HASH_ALGORITHM = "PBKDF2WithHmacSHA256";
private static final String TEMPORAL_KEY_ALGORITHM = "RSA";
private static final int AES_KEY_SIZE = 256;
private static final int RSA_KEY_SIZE = 2048;
private File KEY_STORE_FILE;
private static final String KEY_STORE_NAME = "keyStore";
private static final String KEY_STORE_DIRECTORY_NAME = "security";
private final KeyGenerator[] keyGenerators = new KeyGenerator[TOTAL_CIPHER_UNITS];
private final Cipher[] temporalKeyEncrypters = new Cipher[TOTAL_CIPHER_UNITS];
private final Cipher[] temporalKeyDecrypters = new Cipher[TOTAL_CIPHER_UNITS];
private final Cipher[] payloadEncrypters = new Cipher[TOTAL_CIPHER_UNITS];
private final Cipher[] payloadDecrypters = new Cipher[TOTAL_CIPHER_UNITS];
private final KeyFactory[] keyFactories = new KeyFactory[TOTAL_CIPHER_UNITS];
private final Signature[] signers = new Signature[TOTAL_CIPHER_UNITS];
private static final int TOTAL_CIPHER_UNITS = 14;
@Override
public void init() {
securityTest();
AppViewManager.registerViewsAndDrawer(this);
}
@Override
public void postInit(Scene scene) {
Swatch.BLUE.assignTo(scene);
scene.getStylesheets().add(GluonApplication.class.getResource("style.css").toExternalForm());
((Stage) scene.getWindow()).getIcons().add(new Image(GluonApplication.class.getResourceAsStream("/icon.png")));
}
public static void main(String args[]) {
launch(args);
}
private void securityTest() {
Security.removeProvider("BC");
// also remove not sufficient AndroidOpenSSL provider for X.509 - most likely only needed if BouncyCastleJsseProvider is used
Security.removeProvider("AndroidOpenSSL");
// touch the internal Providers class to trigger the static provider loading
// see http://androidxref.com/9.0.0_r3/xref/libcore/ojluni/src/main/java/sun/security/jca/Providers.java#SYSTEM_BOUNCY_CASTLE_PROVIDER
try {
Class.forName("sun.security.jca.Providers");
} catch (ClassNotFoundException e) {
throw new RuntimeException(String.format("%s to patch not found.", "sun.security.jca.Providers"), e);
}
provider = new BouncyCastleProvider();
Security.insertProviderAt(provider, 0);
final File keyStoreDirectory = new File(System.getProperty("user.home"), KEY_STORE_DIRECTORY_NAME);
// make sure that the path to the directory
keyStoreDirectory.mkdirs();
// create the key store file object
KEY_STORE_FILE = new File(keyStoreDirectory, KEY_STORE_NAME);
for (int i = 0; i < TOTAL_CIPHER_UNITS; i++) {
try {
// we init the key generator with the AES key size
keyGenerators[i] = KeyGenerator.getInstance(KEY_GENERATOR_ALGORITHM, provider);
keyGenerators[i].init(AES_KEY_SIZE);
temporalKeyEncrypters[i] = Cipher.getInstance(TEMPORAL_KEY_ALGORITHM, provider);
temporalKeyDecrypters[i] = Cipher.getInstance(TEMPORAL_KEY_ALGORITHM, provider);
payloadEncrypters[i] = Cipher.getInstance(CIPHER_ALGORITHM, provider);
payloadDecrypters[i] = Cipher.getInstance(CIPHER_ALGORITHM, provider);
keyFactories[i] = KeyFactory.getInstance(KEY_FACTORY_ALGORITHM, provider);
signers[i] = Signature.getInstance(SIGNATURE_ALGORITHM, provider);
} catch (NoSuchPaddingException | NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
}
}
}

如果您发布代码以及完整的堆栈跟踪会更好。

你可以看看这个问题和这个解决方案。

通常,从堆栈跟踪中,您可以检查BC源代码,然后您将能够找到需要为反射添加的类。

我遇到很多情况,错误消息没有显示出与反射有关的内容,但实际上,它是由反射引起的。

相关内容

  • 没有找到相关文章

最新更新