sslengine

SSL and SocketChannel

最后都变了- 提交于 2019-12-03 06:02:54
问题 Ideally, I only need a simple SSLSocketChannel . I already have a component that reads and writes message over ordinary SocketChannel , but for some of these connections, I have to use SSL over the wire; the operations over these connections, however, are the same. Does anyone knows a free SSLSocketChannel implementation (with the appropriate selector) or something similar? I've found this, but the selector doesn't accept it since its vendor isn't SUN. I'm decoupling the reading_from/writing

SSLEngine unwrap() javax.crypto.BadPaddingException: bad record MAC

陌路散爱 提交于 2019-12-02 13:28:48
问题 This has been driving me crazy for a few days now. I created a client using java nio with ssl encryption using an SSLEngine. Handshake works fine, and I write a GET request to a website and it works fine (I get the header with 200 code). The problem is that when the website sends the packets back, on the second packet I get a BadPaddingException. Here is my read method: public void read(SelectionKey key,ByteBuffer readBuffer) throws IOException, BadPaddingException { SocketChannel

SSLEngine unwrap() javax.crypto.BadPaddingException: bad record MAC

﹥>﹥吖頭↗ 提交于 2019-12-02 07:28:40
This has been driving me crazy for a few days now. I created a client using java nio with ssl encryption using an SSLEngine. Handshake works fine, and I write a GET request to a website and it works fine (I get the header with 200 code). The problem is that when the website sends the packets back, on the second packet I get a BadPaddingException. Here is my read method: public void read(SelectionKey key,ByteBuffer readBuffer) throws IOException, BadPaddingException { SocketChannel socketChannel = (SocketChannel) key.channel(); ByteBuffer clientSSLData = ByteBuffer.allocate(getPacketBufferSize(

Java JSSE SSLEngine cannot resume SSL session

ぃ、小莉子 提交于 2019-11-29 15:42:16
I am writing an application that uses SSLEngine with NIO, I writing both the client and the server. The client is able to connect to the server and after he is connected i want him to be able to perform session resumption / renegotiation, but currently without luck.. As the code that uses the SSLEngine is pretty big (SSLEngine usage is SO complex!) i will write a simple pseudo code that demonstrate the situation: Server: global sslcontext initialized once await new client client.sslEngine = create new server ssl engine using the global sslcontext client.handleHandshake and wait for it to be

create an SSLContext instance using a Bouncy Castle provider

泪湿孤枕 提交于 2019-11-29 12:37:54
问题 I'm stuck at the creation of an SSLContext (which I want to use to instantiate an SSLEngine to handle encrypted transport via the java-nio): The code String protocol = "TLSv1.2"; Provider provider = new BouncyCastleProvider(); Security.addProvider(provider); sslContext = SSLContext.getInstance(protocol,provider.getName()); throws the following exception: Exception in thread "main" java.lang.RuntimeException: java.security.NoSuchAlgorithmException: no such algorithm: SSL for provider BC at org

Java JSSE SSLEngine cannot resume SSL session

拈花ヽ惹草 提交于 2019-11-28 09:53:15
问题 I am writing an application that uses SSLEngine with NIO, I writing both the client and the server. The client is able to connect to the server and after he is connected i want him to be able to perform session resumption / renegotiation, but currently without luck.. As the code that uses the SSLEngine is pretty big (SSLEngine usage is SO complex!) i will write a simple pseudo code that demonstrate the situation: Server: global sslcontext initialized once await new client client.sslEngine =

SSL Handshaking Using Self-Signed Certs and SSLEngine (JSSE)

浪尽此生 提交于 2019-11-28 06:37:09
I have been tasked to implement a custom/standalone Java webserver that can process SSL and non-SSL messages on the same port. I have implemented an NIO server and its working quite well for non-SSL requests. I am having a heck of a time with the SSL piece and could really use some guidance. Here's what I have done so far. In order to distinguish between SSL and non-SSL messages, I check the first byte of the inbound request to see if it is a SSL/TLS message. Example: byte a = read(buf); if (totalBytesRead==1 && (a>19 && a<25)){ parseTLS(buf); } In the parseTLS() method I instantiate an

Making SSLEngine use TLSv1.2 on Android (4.4.2)?

こ雲淡風輕ζ 提交于 2019-11-27 11:03:25
Folks, I'm hoping there's something obvious that I'm missing, and I hope someone will be able to shed some light. I'm trying to get TLSv1.2 running in an SSL + NIO context (using the AndroidAsync library), so I'm trying to enable it via an SSLEngine. I can run code like this: SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); sslContext.init(null, null, null); String[] protocols = sslContext.getSupportedSSLParameters().getProtocols(); for (String protocol : protocols) { Timber.d("Context supported protocol: " + protocol); } SSLEngine engine = sslContext.createSSLEngine(); String[]

Making SSLEngine use TLSv1.2 on Android (4.4.2)?

戏子无情 提交于 2019-11-27 04:02:32
问题 Folks, I'm hoping there's something obvious that I'm missing, and I hope someone will be able to shed some light. I'm trying to get TLSv1.2 running in an SSL + NIO context (using the AndroidAsync library), so I'm trying to enable it via an SSLEngine. I can run code like this: SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); sslContext.init(null, null, null); String[] protocols = sslContext.getSupportedSSLParameters().getProtocols(); for (String protocol : protocols) { Timber.d(

SSL Handshaking Using Self-Signed Certs and SSLEngine (JSSE)

北城以北 提交于 2019-11-27 01:29:35
问题 I have been tasked to implement a custom/standalone Java webserver that can process SSL and non-SSL messages on the same port. I have implemented an NIO server and its working quite well for non-SSL requests. I am having a heck of a time with the SSL piece and could really use some guidance. Here's what I have done so far. In order to distinguish between SSL and non-SSL messages, I check the first byte of the inbound request to see if it is a SSL/TLS message. Example: byte a = read(buf); if