{"action":"created","issue":{"url":"https://api.github.com/repos/netty/netty/issues/5704","repository_url":"https://api.github.com/repos/netty/netty","labels_url":"https://api.github.com/repos/netty/netty/issues/5704/labels{/name}","comments_url":"https://api.github.com/repos/netty/netty/issues/5704/comments","events_url":"https://api.github.com/repos/netty/netty/issues/5704/events","html_url":"https://github.com/netty/netty/pull/5704","id":171224557,"number":5704,"title":"Bug in ReferenceCountedOpenSslServerContext#setKeyMaterial ","user":{"login":"rkapsi","id":191635,"avatar_url":"https://avatars.githubusercontent.com/u/191635?v=3","gravatar_id":"","url":"https://api.github.com/users/rkapsi","html_url":"https://github.com/rkapsi","followers_url":"https://api.github.com/users/rkapsi/followers","following_url":"https://api.github.com/users/rkapsi/following{/other_user}","gists_url":"https://api.github.com/users/rkapsi/gists{/gist_id}","starred_url":"https://api.github.com/users/rkapsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkapsi/subscriptions","organizations_url":"https://api.github.com/users/rkapsi/orgs","repos_url":"https://api.github.com/users/rkapsi/repos","events_url":"https://api.github.com/users/rkapsi/events{/privacy}","received_events_url":"https://api.github.com/users/rkapsi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-15T17:57:27Z","updated_at":"2016-08-15T18:08:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/5704","html_url":"https://github.com/netty/netty/pull/5704","diff_url":"https://github.com/netty/netty/pull/5704.diff","patch_url":"https://github.com/netty/netty/pull/5704.patch"},"body":"The private key and certificate that are passed into `#serKeyMaterial()` could be `PemEncoded` in which case the `#toPEM()` methods return the identity of the value.\r\n\r\nThat in turn will fail in the `#toBIO()` step because the underlying ByteBuf is not necessarily direct.\r\n\r\nAttached is a new Unit Test shows the problem.\r\n\r\nThe test will fail with the following error if `assert` are turned on:\r\n```java\r\n13:42:38.595 [main] DEBUG io.netty.handler.ssl.JdkSslContext - Default cipher suites (JDK): [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA]\r\nTests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.121 sec - in io.netty.handler.ssl.JdkSslClientContextTest\r\nRunning io.netty.handler.ssl.PemEncodedTest\r\njava.lang.AssertionError\r\n\tat io.netty.handler.ssl.OpenSsl.memoryAddress(OpenSsl.java:359)\r\n\tat io.netty.handler.ssl.ReferenceCountedOpenSslContext.newBIO(ReferenceCountedOpenSslContext.java:751)\r\n\tat io.netty.handler.ssl.ReferenceCountedOpenSslContext.setKeyMaterial(ReferenceCountedOpenSslContext.java:645)\r\n\tat io.netty.handler.ssl.ReferenceCountedOpenSslServerContext.newSessionContext(ReferenceCountedOpenSslServerContext.java:110)\r\n\tat io.netty.handler.ssl.OpenSslServerContext.<init>(OpenSslServerContext.java:349)\r\n\tat io.netty.handler.ssl.OpenSslServerContext.<init>(OpenSslServerContext.java:334)\r\n\tat io.netty.handler.ssl.SslContext.newServerContextInternal(SslContext.java:412)\r\n\tat io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:393)\r\n\tat io.netty.handler.ssl.PemEncodedTest.testPemEncoded(PemEncodedTest.java:75)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)\r\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\r\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)\r\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\r\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)\r\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)\r\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)\r\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)\r\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)\r\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)\r\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:363)\r\n\tat org.junit.runners.Suite.runChild(Suite.java:128)\r\n\tat org.junit.runners.Suite.runChild(Suite.java:27)\r\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)\r\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)\r\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)\r\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)\r\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)\r\n\tat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)\r\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:363)\r\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)\r\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)\r\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)\r\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)\r\n\tat org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)\r\n\tat org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)\r\n\tat org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)\r\njava.lang.AssertionError\r\n\tat io.netty.handler.ssl.OpenSsl.memoryAddress(OpenSsl.java:359)\r\n\tat io.netty.handler.ssl.ReferenceCountedOpenSslContext.newBIO(ReferenceCountedOpenSslContext.java:751)\r\n\tat io.netty.handler.ssl.ReferenceCountedOpenSslContext.setKeyMaterial(ReferenceCountedOpenSslContext.java:645)\r\n\tat io.netty.handler.ssl.ReferenceCountedOpenSslServerContext.newSessionContext(ReferenceCountedOpenSslServerContext.java:110)\r\n\tat io.netty.handler.ssl.ReferenceCountedOpenSslServerContext.<init>(ReferenceCountedOpenSslServerContext.java:63)\r\n\tat io.netty.handler.ssl.ReferenceCountedOpenSslServerContext.<init>(ReferenceCountedOpenSslServerContext.java:49)\r\n\tat io.netty.handler.ssl.SslContext.newServerContextInternal(SslContext.java:417)\r\n\tat io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:393)\r\n\tat io.netty.handler.ssl.PemEncodedTest.testPemEncoded(PemEncodedTest.java:75)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)\r\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\r\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)\r\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\r\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)\r\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)\r\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)\r\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)\r\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)\r\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)\r\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:363)\r\n\tat org.junit.runners.Suite.runChild(Suite.java:128)\r\n\tat org.junit.runners.Suite.runChild(Suite.java:27)\r\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)\r\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)\r\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)\r\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)\r\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)\r\n\tat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)\r\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:363)\r\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)\r\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)\r\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)\r\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)\r\n\tat org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)\r\n\tat org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)\r\n\tat org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)\r\n```\r\n\r\nIn our testing environment (with no `assert` enabled) it's failing something like along these lines.\r\n\r\n```java\r\nCaused by: javax.net.ssl.SSLException: failed to set certificate and key\r\n    at io.netty.handler.ssl.ReferenceCountedOpenSslServerContext.newSessionContext(ReferenceCountedOpenSslServerContext.java:125)\r\n    at io.netty.handler.ssl.ReferenceCountedOpenSslServerContext.<init>(ReferenceCountedOpenSslServerContext.java:63)\r\n    at io.netty.handler.ssl.ReferenceCountedOpenSslServerContext.<init>(ReferenceCountedOpenSslServerContext.java:49)\r\n    at io.netty.handler.ssl.SslContext.newServerContextInternal(SslContext.java:417)\r\n    at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:393)\r\n    at com.squarespace.xxx(xxx.java:192)\r\n    at com.squarespace.xxx(xxx.java:133)\r\n    at com.squarespace.xxx(xxx.java:111)\r\n    at com.squarespace.xxx(xxx.java:177)\r\n    at com.squarespace.xxx(xxx.java:147)\r\n    at com.squarespace.xxx(xxx.java:27)\r\n    at com.squarespace.xxx(xxx.java:78)\r\n    ... 10 common frames omitted\r\nCaused by: javax.net.ssl.SSLException: failed to set certificate and key\r\n    at io.netty.handler.ssl.ReferenceCountedOpenSslContext.setKeyMaterial(ReferenceCountedOpenSslContext.java:660)\r\n    at io.netty.handler.ssl.ReferenceCountedOpenSslServerContext.newSessionContext(ReferenceCountedOpenSslServerContext.java:110)\r\n    ... 21 common frames omitted\r\nCaused by: java.lang.Exception: wbuf is null\r\n    at org.apache.tomcat.jni.SSL.$$YJP$$writeToBIO(Native Method)\r\n    at org.apache.tomcat.jni.SSL.writeToBIO(SSL.java)\r\n    at io.netty.handler.ssl.ReferenceCountedOpenSslContext.newBIO(ReferenceCountedOpenSslContext.java:751)\r\n    at io.netty.handler.ssl.ReferenceCountedOpenSslContext.setKeyMaterial(ReferenceCountedOpenSslContext.java:645)\r\n    ... 22 common frames omitted\r\n```"},"comment":{"url":"https://api.github.com/repos/netty/netty/issues/comments/239879750","html_url":"https://github.com/netty/netty/pull/5704#issuecomment-239879750","issue_url":"https://api.github.com/repos/netty/netty/issues/5704","id":239879750,"user":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars.githubusercontent.com/u/439362?v=3","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"created_at":"2016-08-15T18:08:27Z","updated_at":"2016-08-15T18:08:27Z","body":"@rkapsi the `newBio(...)` is called to reduce the overhead. Let me check what is going on."}}
{"actor":{"display_login":"normanmaurer"}}