gpt4 book ai didi

java - Silvertunnel异常: java. lang.NoSuchMethodError : org. bouncycaSTLe.asn1.ASN1InputStream.readObject()Lorg/bouncycaSTLe/asn1/DERObject;

转载 作者:太空宇宙 更新时间:2023-11-04 13:02:07 40 4
gpt4 key购买 nike

我正在尝试使用 silvertunnel netlib 连接到 tor 隐藏服务,但我不断遇到相同的异常:

Exception in thread "org.silvertunnel.netlib.layer.tor.directory.DirectoryManagerThread" java.lang.NoSuchMethodError: org.bouncycastle.asn1.ASN1InputStream.readObject()Lorg/bouncycastle/asn1/DERObject; at org.bouncycastle.openssl.PEMReader.readRSAPublicKey(PEMReader.java:193) at org.bouncycastle.openssl.PEMReader.readObject(PEMReader.java:110) at org.silvertunnel.netlib.layer.tor.util.Encryption.extractPublicRSAKey(Encryption.java:342) at org.silvertunnel.netlib.layer.tor.directory.AuthorityKeyCertificate.(AuthorityKeyCertificate.java:104) at org.silvertunnel.netlib.layer.tor.directory.AuthorityKeyCertificates.(AuthorityKeyCertificates.java:100) at org.silvertunnel.netlib.layer.tor.directory.AuthorityKeyCertificates.(AuthorityKeyCertificates.java:80) at org.silvertunnel.netlib.layer.tor.directory.Directory.getAuthorityKeyCertificates(Directory.java:492) at org.silvertunnel.netlib.layer.tor.directory.Directory.updateNetworkStatusNew(Directory.java:324) at org.silvertunnel.netlib.layer.tor.directory.Directory.refreshListOfServers(Directory.java:287) at org.silvertunnel.netlib.layer.tor.directory.DirectoryManagerThread.updateDirectory(DirectoryManagerThread.java:60) at org.silvertunnel.netlib.layer.tor.directory.DirectoryManagerThread.run(DirectoryManagerThread.java:76)

我尝试过不同版本的 bouncycaSTLe,但我就是无法让它工作。有谁知道可能是什么问题吗?

这是我的代码:

String host = "some_site.onion";
int port = 7878;
TcpipNetAddress remoteAddress = new TcpipNetAddress(host, port);
NetLayer netLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TOR);
netLayer.waitUntilReady();
NetSocket netSocket = netLayer.createNetSocket(null, null, remoteAddress);
BufferedReader br = new BufferedReader(new InputStreamReader(netSocket.getInputStream()));
System.out.println(br.readLine());
br.close();
netSocket.close();

最佳答案

您的 java 安装中可能有一个 bouncy caSTLe 版本,而导致此错误的原因是一个版本试图调用另一版本。检查您的 JAVA_HOME/jre/lib/ext/JAVA_HOME/lib 目录中是否有名称以“bcprov”开头的文件。

<小时/>

好吧,既然你评论说这不起作用,我仍然认为你的类路径上有多个版本的 bouncycaSTLe。具体来说,我认为您有不同版本的 bcprov 和 bcpkix jar。因此,让我们编写一个简短的 java 程序来查找它们:

import java.net.URL;
import java.util.Enumeration;

public class FindBouncy {
static void printResources(String n) throws Exception {
Enumeration<URL> e = FindBouncy.class.getClassLoader().getResources(n);
if (!e.hasMoreElements()) {
System.out.println(n + " not found!");
} else {
System.out.println(n + " found as:");
while(e.hasMoreElements()) {
System.out.println(" " + e.nextElement());
}
}
}
public static void main(String argv[]) throws Exception {
printResources("org/bouncycastle/openssl/PEMReader.class");
printResources("org/bouncycastle/asn1/ASN1InputStream.class");
}
}

在 eclipse 中运行它,并找到“PEMReader”类(旧版本 bcpkix jar 中的旧类)和“ASN1InputStream”类(应同时包含在旧版和新版 bcprov jar 中的类)的来源。使用这些相互匹配的 jar 版本。

关于java - Silvertunnel异常: java. lang.NoSuchMethodError : org. bouncycaSTLe.asn1.ASN1InputStream.readObject()Lorg/bouncycaSTLe/asn1/DERObject;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34840297/

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