我正在尝试使用 silvertunnel netlib 连接到一个 tor 隐藏服务,但我一直遇到同样的异常:
线程“org.silvertunnel.netlib.layer.tor.directory.DirectoryManagerThread”中的异常 java.lang.NoSuchMethodError: org.bouncycastle.asn1.ASN1InputStream.readObject()Lorg/bouncycastle/asn1/DERObject; org.bouncycastle.openssl.PEMReader.readRSAPublicKey(PEMReader.java:193) org.silvertunnel.netlib.layer.tor.util.Encryption.extractPublicRSAKey org.bouncycastle.openssl.PEMReader.readObject(PEMReader.java:110) (Encryption.java:342) 在 org.silvertunnel.netlib.layer.tor.directory.AuthorityKeyCertificate.(AuthorityKeyCertificate.java:104) 在 org.silvertunnel.netlib.layer.tor.directory.AuthorityKeyCertificates.(AuthorityKeyCertificates.java:100) ) 在 org.silvertunnel.netlib.layer.tor.directory 的 org.silvertunnel.netlib.layer.tor.directory.AuthorityKeyCertificates.(AuthorityKeyCertificates.java:80)。
我尝试了不同版本的 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();