- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在使用 SSLEngine
时遇到了一个小问题 java 。我用它来创建客户端和服务器之间的 SSL 连接。这不是基于 Web 的应用程序。
我正在为我的产品开发人员创建一个框架,以便在客户端和服务器之间进行通信。根据他们的配置,我必须创建连接。如果需要加密,我必须创建一个加密 channel 并提供给他们;如果没有,我只需要创建一个没有加密但有消息摘要的 SSL channel ,所以我需要启用的密码套件是 SSL_RSA_WITH_NULL_MD5
.如果需要加密,我会使用SSL_RSA_WITH_<some encryption algo>_SHA/MD5
.
我可以配置第二个……但无法配置 SSL_RSA_WITH_NULL_MD5
.它给我一个异常消息 No cypher suites in common
.我开发这个的框架是Netty(jboss-netty)。
谁能帮我解决这个问题??
代码::
public static ChannelFuture doHandshake(Channel channel,boolean isServer){
if (isServer) {
SSLEngine engine = SslContextFactory.getServerContext().createSSLEngine();
engine.setUseClientMode(false);
//engine.setWantClientAuth(true);
engine.setNeedClientAuth(true);
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
String[] enabledSuites = engine.getEnabledCipherSuites();
//String[] sdf = engine.getSupportedCipherSuites();
engine.setEnabledCipherSuites(getWantedCyphers(enabledSuites, true));
engine.setEnableSessionCreation(true);
channel.getPipeline().addFirst(SSL_SERVER_HANDLER_NAME, new SslHandler(engine));
SslHandler sslHandler = (SslHandler) channel.getPipeline().get(SSL_SERVER_HANDLER_NAME);
sslHandler.setEnableRenegotiation(true);
return sslHandler.handshake();
} else {
SSLEngine engine = SslContextFactory.getClientContext().createSSLEngine();
engine.setUseClientMode(true);
engine.setEnableSessionCreation(true);
//engine.setWantClientAuth(true);
//engine.setNeedClientAuth(true);
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
String[] enabledSuites=engine.getEnabledCipherSuites();
//String[] sdf=engine.getSupportedCipherSuites();
engine.setEnabledCipherSuites(getWantedCyphers(enabledSuites,true));
channel.getPipeline().addFirst(SSL_CLIENT_HANDLER_NAME, new SslHandler(engine));
SslHandler sslHandler = (SslHandler) channel.getPipeline().get(SSL_CLIENT_HANDLER_NAME);
sslHandler.setEnableRenegotiation(true);
return sslHandler.handshake();
}
}
public static String[] getWantedCyphers(String[] enabledSuites,boolean isEnabled) {
List<String> wantedCyphers = new LinkedList<String>();
String[] finalEnabledCyphers = null;
if (!isEnabled) {
finalEnabledCyphers = new String[1];
finalEnabledCyphers[0] = "SSL_RSA_WITH_NULL_MD5";
return finalEnabledCyphers;
}
String configFilePath = TestConstants.CONFIG_FILE;
ConfigSAXParser configParser = new ConfigSAXParser();
<OurOwnConfigClass>config = null;
try {
config = (<OurOwnConfigClass>(configParser.parseFile(configFilePath));
} catch (SAXParserException spe){
}
<ourOwnConfigSubClass> communicationConfig = config.getCommunicationConfig();
String[] requestedCyphers = communicationConfig.getEncryptionAlgorithms();
for (int i=0;i<requestedCyphers.length;i++){
requestedCyphers[i] = "SSL_RSA_WITH_"+requestedCyphers[i]+"_SHA";
}
List<String> stList = new LinkedList<String>();
for (int i=0;i<enabledSuites.length;i++) {
stList.add(enabledSuites[i]);
}
for (int j=0;j<requestedCyphers.length;j++) {
if (stList.contains(requestedCyphers[j])) {
wantedCyphers.add(requestedCyphers[j]);
}
}
Object[] strings = wantedCyphers.toArray();
finalEnabledCyphers = new String[strings.length];
for (int k=0;k<strings.length;k++) {
finalEnabledCyphers[k] = (String)strings[k];
}
return finalEnabledCyphers;
}
最佳答案
您是否已将其添加到已启用的密码套件中?
关于java - 没有加密的 sslengine 密码套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4363632/
我正在使用 Java NIO 上的 SSLEngine 来解锁服务器套接字来处理连接。我能够成功地与客户端握手并将小记录集传递到服务器。但是,当我尝试将文件传输到服务器 text/binary 时,出
我已经实现了一个辅助模块,可以让我从使用 SSL 的 channel 获取干净数据并将加密数据写入其中:这是相关接口(interface)(我在该类中也有一些非抽象方法,所以没有不要对我说“DataP
我遇到了这个异常发生 SSLEngineResult result = sslEngine.wrap(b, engineToSocketData); if(b.hasRemaining
在 Java 中有没有一种方法可以具有与 SSLEngine 相同的功能,但没有委托(delegate)任务,因为我的程序需要处理大量连接,我用 NIO 编写它的目的是使用更少的 ram,有更多的连接
我正在尝试使用 SSLEngine 实现 SSL 握手,我需要同时作为服务器和客户端来执行此操作,但是我被卡住了,我无法弄清楚原因。 握手正确开始,交换了 Hello,交换了 key ,但随后我进入了
SSLEngine documentation指示如何正确关闭 SSL 连接。更具体地说,它提供了有关如何处理断开的连接的说明: In addition to orderly shutdowns, t
我需要为我正在开发的应用程序使用基于 TLS 的 TCP 套接字。我已经经历了几十个例子,虽然我通过握手没有问题,但我似乎无法通过任何方式读取输入流(尝试了很多,包括 readline(),读取字符数
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 2 年前。
我正在尝试在非阻塞模式下将 SSLengine 与 SocketChannels 一起使用。 握手已正确完成,但当我尝试从 channelsocket 读取和解密 http 帖子时,只有标题被解密,正
背景 我正在尝试创建 2 个通过 SSL 在内部网络上相互通信的 Java 应用程序。我通过授予 SSLEngine 访问 keystore 的权限来做到这一点,该 keystore 包含要使用的证书
我在使用 SSLEngine 时遇到了一个小问题 java 。我用它来创建客户端和服务器之间的 SSL 连接。这不是基于 Web 的应用程序。 我正在为我的产品开发人员创建一个框架,以便在客户端和服务
我正在为 Android 手机编写自定义服务器来处理 https 请求。它首先监听特定端口,一旦建立连接,它就会与客户端进行握手。这是代码 fragment : ServerSocket sock =
我使用来自 http://books.google.com/books?id=l6f1jTB_XCYC&lpg=PA185&vq=scalable%20secure&pg=PA185#v=onepag
我在 Java 中使用带有 NIO 的 SSL 和一个简单的客户端/服务器概念验证应用程序。我已经启动并运行良好的握手,但之后尝试加密和解密应用程序数据让我抓狂。我想知道我是否遗漏了预期用途方面的内容
当为 ssl/https 连接配置 apache2 虚拟主机时,在添加配置并使用此命令“a2ensite pm.university.com.conf”启用配置后,我收到此错误“无效命令‘SSLEng
我有一个 Java 服务器应用程序(加载了它自己的服务器证书)试图安全地连接到另一个服务器(Microsoft - 有它的服务器证书)。 他们每个人都加载了受信任的 ROOT-CA 证书,我可以在两台
我将 SSLEngine 与 NIO 一起使用,为我的应用程序提供非阻塞 SSL 连接。在握手期间的某个时刻(可能是在收到 ServerHelloDone 之后),SSLEngine 要求我处理委托(
我有下一个案例:客户端在其信任库中只有根证书。在 TLS 握手期间,服务器将自己的证书发送给客户端,该证书使用中间证书 签名。 客户端的 SLLEngine 是否会下载中间证书来验证服务器证书,直到引
我需要通过我的代理(我相信是隧道)建立一个使用 JSSE 建立的 SSL 连接。是否已经有任何库/属性/方法,或者我必须在低级别实现它? 请注意,只需为我的程序的一个子集定义此代理。我程序中的其他 H
来自 SSLEngine 文档:“通过将 SSL/TLS 抽象与 I/O 传输机制分离,SSLEngine 可用于各种 I/O 类型,例如非阻塞 I/O(轮询) ,可选择的非阻塞 I/O,Socket
我是一名优秀的程序员,十分优秀!