gpt4 book ai didi

java - 带有 bouncycaSTLe jar 错误的 Maven

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:13:36 27 4
gpt4 key购买 nike

我在 maven 的 pom.xml 中使用以下依赖项:

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.55</version>
</dependency>

在 eclipse 中运行项目后,一切正常。通过使用 eclipse 的导出功能,创建一个可运行的 jar 文件,包括所有依赖项,一切正常。没有设置eclipse中的其他参数或配置。

只有当我运行 mvn 构建时,某些东西似乎是错误的。(Maven 构建运行时没有任何错误或警告)--> 依赖都包含在内。

在尝试建立https连接的那一刻发生了错误,这个地方使用了这个bouncycaSTLe库。

错误:

javax.net.ssl.SSLException: java.security.ProviderException: Could not derive key
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.SSLSocketImpl.handleException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:553)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:412)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:179)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:328)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:612)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:447)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:884)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at plugin.KITIlias.executePost(KITIlias.java:117)
at plugin.KITIlias.login(KITIlias.java:45)
at control.IliasManager.login(IliasManager.java:27)
at control.IliasStarter.login(IliasStarter.java:31)
at control.LoginProvider$1.run(LoginProvider.java:56)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.ProviderException: Could not derive key
at sun.security.ec.ECDHKeyAgreement.engineGenerateSecret(ECDHKeyAgreement.java:133)
at sun.security.ec.ECDHKeyAgreement.engineGenerateSecret(ECDHKeyAgreement.java:163)
at javax.crypto.KeyAgreement.generateSecret(KeyAgreement.java:648)
at sun.security.ssl.ECDHCrypt.getAgreedSecret(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverHelloDone(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
... 16 more
Caused by: java.security.InvalidAlgorithmParameterException
at sun.security.ec.ECDHKeyAgreement.deriveKey(Native Method)
at sun.security.ec.ECDHKeyAgreement.engineGenerateSecret(ECDHKeyAgreement.java:130)
... 25 more
Exception in thread "Thread-4" java.lang.NullPointerException
at plugin.KITIlias.executePost(KITIlias.java:125)
at plugin.KITIlias.login(KITIlias.java:45)
at control.IliasManager.login(IliasManager.java:27)
at control.IliasStarter.login(IliasStarter.java:31)
at control.LoginProvider$1.run(LoginProvider.java:56)
at java.lang.Thread.run(Unknown Source)

所以对我来说,在 maven 构建过程中似乎缺少了一些东西。是否需要签署其中一个 jar ?

我完整的pom.xml是

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>X</groupId>
<artifactId>Y</artifactId>
<version>v1.1.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>8.20.8</version>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.55</version>
</dependency>


</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>view.Dashboard</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

我正在获取可运行的 jar:

mvn clean install

编辑:来自 eclipse 导出的 list 文件

Manifest-Version: 1.0
Rsrc-Class-Path: ./ junit-4.10.jar hamcrest-core-1.1.jar log4j-1.2.17.
jar jsoup-1.7.2.jar httpcore-4.4.5.jar httpclient-4.5.2.jar commons-c
odec-1.9.jar commons-logging-1.1.1.jar controlsfx-8.20.8.jar openjfx-
dialogs-1.0.2.jar bcprov-jdk15on-1.55.jar
Class-Path: .
Rsrc-Main-Class: view.Dashboard
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

-> 似乎仍然依赖于 eclipse

最佳答案

问题似乎出在必须对来自 bouncycaSTLe 的依赖项进行签名。如果 maven 将它重新打包到另一个 jar 中,则该 jar 不再签名。解决方案是将所有依赖项保留在 jar 文件旁边并添加一个类路径目录。现在主jar可以直接使用签名jar了。

(不过我真的更喜欢一个单独的 jar 文件)

关于java - 带有 bouncycaSTLe jar 错误的 Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40047037/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com