cb4020d4be
Motivation: Although 4cff4b99fd9bcaf256fa62699309e7beff8a136b introduced OpenSslEngine and its helper classes, a user has to write two different copies of SSL initialization code that does pretty much same job, because the initialization procedure between JDK SSLEngine and OpenSslEngine are different. Modifications: - Replace OpenSslContextBuilder with SslContext which provides the unified API for creating an SSL context - SslContext allows you to create a new SSLEngine or a new SslHandler with your PKCS#8 key and X.509 certificate chain. - Merge OpenSslBufferPool into SslBufferPool - Add an option to preallocate the pool - Add an option to allocate direct buffers - When OpenSSL is in use, preallocate direct buffers, which is close to what OpenSslBufferPool does. - Add JdkSslContext which is a simple wrapper of JDK's SSLContext - The specified PKCS#8 key and X.509 certificate chain are converted to JDK KeyStore in instantiation time. - Like OpenSslServerContext, it uses sensible default cipher suites now. - A user does not specify certPath and caPath separately anymore. He or she has to merge them into a single file. I find this more logical because previously ca file's first entry and cert file were always same. - Clean up SSL tests to demonstrate the advantage of this change - AbstractSocketSsl*Test now uses SslContext.new*Context() to configure both the client and the server side. We did this only for the server side previously and had to use different certificates for JDK SSLEngine and OpenSslEngine, but not anymore. - Add ApplicationProtocolSelector to ensure the future support for NPN (NextProtoNego) and ALPN (Application Layer Protocol Negotiation) on the client-side. - Add SimpleTrustManagerFactory to help a user write a TrustManagerFactory easily, which should be useful for those who need to write an alternative verification mechanism. For example, we can use it to implement an unsafe TrustManagerFactory that accepts self-signed certificates for testing purposes. - Add InsecureTrustManagerFactory and FingerprintTrustManager for quick and dirty testing - Add SelfSignedCertificate class which generates a self-signed X.509 certificate very easily. - Update all our examples to use SslContext.newClient/ServerContext() - Found that OpenSslEngine performs unnecessary memory copy - optimized it. - SslHandler now logs the chosen cipher suite when handshake is finished. Result: - Cleaner unified API for configuring an SSL client and an SSL server regardless of its internal implementation. - When native libraries are available, OpenSSL-based SSLEngine implementation is selected automatically to take advantage of its performance benefit. - Examples take advantage of this modification and thus are cleaner.
24 lines
1.1 KiB
Plaintext
24 lines
1.1 KiB
Plaintext
The MIT License (MIT)
|
|
|
|
Copyright (c) 2000 - 2013 The Legion of the Bouncy Castle Inc.
|
|
(http://www.bouncycastle.org)
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE.
|
|
|