You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by bu...@apache.org on 2019/04/03 10:33:52 UTC
svn commit: r1043104 - in /websites/staging/mina/trunk/content: ./
mina-project/ mina-project/technical-documentation/
mina-project/userguide/ch11-ssl-filter/
Author: buildbot
Date: Wed Apr 3 10:33:52 2019
New Revision: 1043104
Log:
Staging update by buildbot for mina
Added:
websites/staging/mina/trunk/content/mina-project/technical-documentation/
websites/staging/mina/trunk/content/mina-project/technical-documentation/message-flow.html
websites/staging/mina/trunk/content/mina-project/technical-documentation/ssl-tls-internal.html
Modified:
websites/staging/mina/trunk/content/ (props changed)
websites/staging/mina/trunk/content/mina-project/documentation.html
websites/staging/mina/trunk/content/mina-project/userguide/ch11-ssl-filter/ch11-ssl-filter.html
Propchange: websites/staging/mina/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Apr 3 10:33:52 2019
@@ -1 +1 @@
-1856393
+1856869
Modified: websites/staging/mina/trunk/content/mina-project/documentation.html
==============================================================================
--- websites/staging/mina/trunk/content/mina-project/documentation.html (original)
+++ websites/staging/mina/trunk/content/mina-project/documentation.html Wed Apr 3 10:33:52 2019
@@ -228,9 +228,9 @@ The MINA 2.0 User Guide can be found her
<li><a href="quick-start-guide.html">MINA v2.0 Quick Start Guide</a> - Create your first MINA based program using MINA version 2.0</li>
<li><a href="userguide/ch12-logging-filter/ch12-logging-filter.html">Logging Configuration</a> - Configuring your MINA-based application for logging</li>
<li>Transport-specific Configuration<ul>
-<li><a href="userguide/ch6-transports/serial-transport.html">Serial Tutorial</a> - Serial communications with MINA trunk</li>
+<li><a href="userguide/ch6-transports/ch6.2-serial-transport.html">Serial Tutorial</a> - Serial communications with MINA trunk</li>
<li><a href="userguide/ch6-transports/ch6-transports">UDP Tutorial</a> - Writing a User Datagram Protocol (UDP) client and server using MINA</li>
-<li><a href="userguide/ch6-transports/apr-transport.html">APR Transport</a> - Describes use of APR Transport with MINA</li>
+<li><a href="userguide/ch6-transports/ch6.1-apr-transport.html">APR Transport</a> - Describes use of APR Transport with MINA</li>
</ul>
</li>
<li><a href="userguide/ch17-spring-integration/ch17-spring-integration.html">Integrating with Spring</a> - Demonstrates how to integrate MINA application with Spring</li>
Added: websites/staging/mina/trunk/content/mina-project/technical-documentation/message-flow.html
==============================================================================
--- websites/staging/mina/trunk/content/mina-project/technical-documentation/message-flow.html (added)
+++ websites/staging/mina/trunk/content/mina-project/technical-documentation/message-flow.html Wed Apr 3 10:33:52 2019
@@ -0,0 +1,361 @@
+<!DOCTYPE html>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+ <title>Message flow — Apache MINA</title>
+
+ <link href="./../../css/common.css" rel="stylesheet" type="text/css">
+ <link href="./../../css/mina.css" rel="stylesheet" type="text/css">
+
+
+ <link rel="shortcut icon" href="./../../staticresources/images/mina-icon_16x16.png"/>
+
+</head>
+ <body>
+ <div id="container">
+ <div id="header">
+ <div id="subProjectsNavBar">
+ <a href="./../../">
+
+ Apache MINA Project
+
+ </a>
+ |
+ <a href="./../../mina-project/index.html">
+
+ <strong>MINA</strong>
+
+ </a>
+ |
+ <a href="./../../asyncweb-project/index.html">
+
+ AsyncWeb
+
+ </a>
+ |
+ <a href="./../../ftpserver-project/index.html">
+
+ FtpServer
+
+ </a>
+ |
+ <a href="./../../sshd-project/index.html">
+
+ SSHD
+
+ </a>
+ |
+ <a href="./../../vysper-project/index.html">
+
+ Vysper
+
+ </a>
+ </div><!-- subProjectsNavBar -->
+ </div><!-- header -->
+ <div id="content">
+ <div id="leftColumn">
+
+
+
+
+
+ <style type="text/css">
+/* The following code is added by mdx_elementid.py
+ It was originally lifted from http://subversion.apache.org/style/site.css */
+/*
+ * Hide class="elementid-permalink", except when an enclosing heading
+ * has the :hover property.
+ */
+.headerlink, .elementid-permalink {
+ visibility: hidden;
+}
+h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
+<div id="navigation">
+
+ <h5>Latest Downloads</h5>
+ <ul>
+ <li><a href="./../../mina-project/downloads_2_0.html">Mina 2.0.20</a></li>
+ <li><a href="./../../mina-project/downloads_2_1.html">Mina 2.1.0</a></li>
+ <li><a href="./../../mina-project/downloads_old.html">Mina old versions</a></li>
+ </ul>
+ <h5>Documentation</h5>
+ <ul>
+ <li><a href="./../../mina-project/documentation.html" class="external-link" rel="nofollow">Base documentation</a></li>
+ <li><a href="./../../mina-project/userguide/user-guide-toc.html" class="external-link" rel="nofollow">User guide</a></li>
+ <li><a href="./../../mina-project/2.1-vs-2.0.html" class="external-link" rel="nofollow">2.1 vs 2.0</a></li>
+ <li><a href="./../../mina-project/features.html" class="external-link" rel="nofollow">Features</a></li>
+ <li><a href="./../../mina-project/road-map.html" class="external-link" rel="nofollow">Road Map</a></li>
+ <li><a href="./../../mina-project/quick-start-guide.html" class="external-link" rel="nofollow">Quick Start Guide</a></li>
+ <li><a href="./../../mina-project/faq.html" class="external-link" rel="nofollow">FAQ</a></li>
+ </ul>
+ <h5>Resources</h5>
+ <ul>
+ <li><a href="./../../mina-project/mailing-lists.html" class="external-link" rel="nofollow">Mailing lists & IRC</a></li>
+ <li><a href="./../../mina-project/issue-tracking.html" class="external-link" rel="nofollow">Issue tracking</a></li>
+ <li><a href="./../../mina-project/sources.html" class="external-link" rel="nofollow">Sources</a></li>
+ <li><a href="./../../mina-project/gen-docs/latest-2.0/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.0.20</a></li>
+ <li><a href="./../../mina-project/gen-docs/latest-2.1/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.1.0</a></li>
+ <li><a href="./../../mina-project/gen-docs/latest-2.0/xref/index.html" class="external-link" rel="nofollow">API xref 2.0.20</a></li>
+ <li><a href="./../../mina-project/gen-docs/latest-2.1/xref/index.html" class="external-link" rel="nofollow">API xref 2.1.0</a></li>
+ <li><a href="./../../mina-project/performances.html" class="external-link" rel="nofollow">Performances</a></li>
+ <li><a href="./../../mina-project/testimonials.html" class="external-link" rel="nofollow">Testimonials</a></li>
+ <li><a href="./../../mina-project/conferences.html" class="external-link" rel="nofollow">Conferences</a></li>
+ <li><a href="./../../mina-project/developer-guide.html" class="external-link" rel="nofollow">Developers Guide</a></li>
+ <li><a href="./../../mina-project/related-projects.html" class="external-link" rel="nofollow">Related Projects</a></li>
+ <li><a href="https://people.apache.org/~vgritsenko/stats/projects/mina.html" class="external-link" rel="nofollow">Statistics</a></li>
+ </ul>
+
+
+ <h5>Community</h5>
+ <ul>
+ <li><a href="https://www.apache.org/foundation/contributing.html" class="external-link" rel="nofollow">Contributing</a></li>
+ <li><a href="./../../contributors.html" class="external-link" rel="nofollow">Team</a></li>
+ <li><a href="./../../special-thanks.html" class="external-link" rel="nofollow">Special Thanks</a></li>
+ <li><a href="https://www.apache.org/security/" class="external-link" rel="nofollow">Security</a></li>
+ </ul>
+
+
+ <h5>About Apache</h5>
+ <ul>
+ <li><a href="https://www.apache.org" class="external-link" rel="nofollow">Apache main site</a></li>
+ <li><a href="https://www.apache.org/licenses/" class="external-link" rel="nofollow">License</a></li>
+ <li><a href="https://www.apache.org/foundation/sponsorship.html" title="The ASF sponsorship program" class="external-link" rel="nofollow">Sponsorship program</a></li>
+ <li><a href="https://www.apache.org/foundation/thanks.html" class="external-link" rel="nofollow">Thanks</a></li>
+ </ul>
+
+
+ <h3><a name="Navigation-Upcoming"></a>Upcoming</h3>
+ <ul>
+ <li>No event</li>
+ </ul>
+
+</div>
+
+<!-- navigation -->
+
+
+ </div><!-- leftColumn -->
+ <div id="rightColumn">
+
+
+
+
+<style type="text/css">
+/* The following code is added by mdx_elementid.py
+ It was originally lifted from http://subversion.apache.org/style/site.css */
+/*
+ * Hide class="elementid-permalink", except when an enclosing heading
+ * has the :hover property.
+ */
+.headerlink, .elementid-permalink {
+ visibility: hidden;
+}
+h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
+<h1 id="message-flow">Message flow<a class="headerlink" href="#message-flow" title="Permanent link">¶</a></h1>
+<p>When a selector receives some <em>OP_READ</em> event, the associated <em>IoProcessor</em> is awaken and starts to process this event. It all starts with reading the channel, then pushing the read data through the filter chain down to the <em>IoHandler</em> (aka, the application). If the application decides to write back a response, it goes through the chain again, andultimately the data to be pushed into the channel is pushed into a queue (<em>writeRequestQueue), then the stack is unfolled, down to the _IoProcessor</em>, which pops the data from the queue and writes it into the channel.</p>
+<p>Here is the representation of such a flow, where the <em>SslFilter</em> has been included (we will come back to it later)</p>
+<p>::: text
+ +-------------------+
+ | IoAcceptor |
+ | +---------+ |
+ | | Select | |
+ | +----+----+ |
+ | | |
+ +---------+---------+
+ . flush/
+ +---------+ . +---------+ wakeup
+ | Channel <-----read------+ . +-----write-----> Channel | +----+
+ +---------+ | | | +---------+ | |
+ +---+--v--+---+ +----v----+---+
+ | | writeRequestQueue | |
+ | IoProcessor | +-+-+-+-+-+-+-+-+ | IoProcessor |
+ | <- pop -+ | | | | | | | <- put- | |
+ +---+-----^---+ +-+-+-+-+-+-+-+-+ +---------^---+
+ | . . |
+ fireMessageReceived | . . | write
+ | . . |
+ +---v---------+ +---v-----+---+
+ | HeadFilter | | HeadFilter <---------------filterWrite---------------+
+ +---+-----^---+ +-------------+ |
+ | . . +-----+------+
+ MessageReceived | . . +----------flushScheduledEvents--------> SslHandler |
+ | . . | +-----+------+
+ +---v---------+ +---v------+--+ |
+ | SslFilter | | SslFilter +----put----+ |
+ +---+-----^---+ +---------^---+ | |
+ | . . | | filterWriteQueue |
+ MessageReceived | . . | filterWrite | +-+-+-+-+-+-+-+-+ |
+ | . . | +--> | | | | | | | <----pop---+
+ +---v---------+ +---v---------+ +-+-+-+-+-+-+-+-+
+ | <filters> | | <filters> |
+ +---+-----v---+ +-------------+
+ | . . |
+ MessageReceived | . . | filterWrite
+ | . . |
+ +---v---------+ +---v-----+---+
+ | TailFilter | | TailFilter |
+ +---+-----^---+ +---------^---+
+ | . . |
+ MessageReceived | . . | fireFilterWrite
+ | . . |
+ +---v---------+ . |
+ | IoHandler | . |
+ +---+-----^---+ . |
+ | . . |
+ | ......................................... |
+ | |
+ +-------------------sessionWrite--------------------+</p>
+<p>For instance, if we consider an application which filter chain contains the <em>MdcInjectionFilter</em>, <em>SslFilter</em>, <em>CompressionFilter</em>, <em>ProtocolCodecFilter</em>, <em>LoggingFilter</em>, we end uo with a stack of 77 calls, which needs to be emptied before the response can eventually be written. Here is the stack (in reverse order, the latest call on top of it):</p>
+<p>::: text
+ NioProcessor(AbstractPollingIoProcessor<S>).flush(S) line: 449<br />
+ NioProcessor(AbstractPollingIoProcessor<S>).write(S, WriteRequest) line: 436<br />
+ NioProcessor(AbstractPollingIoProcessor<S>).write(IoSession, WriteRequest) line: 68
+ SimpleIoProcessorPool<S>.write(S, WriteRequest) line: 278
+ SimpleIoProcessorPool<S>.write(IoSession, WriteRequest) line: 80<br />
+ DefaultIoFilterChain$HeadFilter.filterWrite(IoFilter$NextFilter, IoSession, WriteRequest) line: 914
+ DefaultIoFilterChain.callPreviousFilterWrite(IoFilterChain$Entry, IoSession, WriteRequest) line: 753<br />
+ DefaultIoFilterChain.access$1500(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, WriteRequest) line: 49
+ DefaultIoFilterChain$EntryImpl$1.filterWrite(IoSession, WriteRequest) line: 1146<br />
+ IoFilterEvent.fire() line: 131<br />
+ MdcInjectionFilter.filter(IoFilterEvent) line: 162<br />
+ MdcInjectionFilter(CommonEventFilter).filterWrite(IoFilter$NextFilter, IoSession, WriteRequest) line: 68<br />
+ DefaultIoFilterChain.callPreviousFilterWrite(IoFilterChain$Entry, IoSession, WriteRequest) line: 753<br />
+ DefaultIoFilterChain.access$1500(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, WriteRequest) line: 49
+ DefaultIoFilterChain$EntryImpl$1.filterWrite(IoSession, WriteRequest) line: 1146<br />
+ SslHandler.flushScheduledEvents() line: 330
+ SslFilter.filterWrite(IoFilter$NextFilter, IoSession, WriteRequest) line: 671
+ DefaultIoFilterChain.callPreviousFilterWrite(IoFilterChain$Entry, IoSession, WriteRequest) line: 753<br />
+ DefaultIoFilterChain.access$1500(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, WriteRequest) line: 49
+ DefaultIoFilterChain$EntryImpl$1.filterWrite(IoSession, WriteRequest) line: 1146<br />
+ CompressionFilter.filterWrite(IoFilter$NextFilter, IoSession, WriteRequest) line: 152
+ DefaultIoFilterChain.callPreviousFilterWrite(IoFilterChain$Entry, IoSession, WriteRequest) line: 753<br />
+ DefaultIoFilterChain.access$1500(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, WriteRequest) line: 49
+ DefaultIoFilterChain$EntryImpl$1.filterWrite(IoSession, WriteRequest) line: 1146<br />
+ ProtocolCodecFilter.filterWrite(IoFilter$NextFilter, IoSession, WriteRequest) line: 340
+ DefaultIoFilterChain.callPreviousFilterWrite(IoFilterChain$Entry, IoSession, WriteRequest) line: 753<br />
+ DefaultIoFilterChain.access$1500(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, WriteRequest) line: 49
+ DefaultIoFilterChain$EntryImpl$1.filterWrite(IoSession, WriteRequest) line: 1146<br />
+ LoggingFilter(IoFilterAdapter).filterWrite(IoFilter$NextFilter, IoSession, WriteRequest) line: 138<br />
+ DefaultIoFilterChain.callPreviousFilterWrite(IoFilterChain$Entry, IoSession, WriteRequest) line: 753<br />
+ DefaultIoFilterChain.access$1500(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, WriteRequest) line: 49
+ DefaultIoFilterChain$EntryImpl$1.filterWrite(IoSession, WriteRequest) line: 1146<br />
+ DefaultIoFilterChain$TailFilter(IoFilterAdapter).filterWrite(IoFilter$NextFilter, IoSession, WriteRequest) line: 138<br />
+ DefaultIoFilterChain.callPreviousFilterWrite(IoFilterChain$Entry, IoSession, WriteRequest) line: 753<br />
+ DefaultIoFilterChain.fireFilterWrite(WriteRequest) line: 746<br />
+ NioSocketSession(AbstractIoSession).write(Object, SocketAddress) line: 570<br />
+ NioSocketSession(AbstractIoSession).write(Object) line: 515
+ ChatProtocolHandler.messageReceived(IoSession, Object) line: 106<br />
+ DefaultIoFilterChain$TailFilter.messageReceived(IoFilter$NextFilter, IoSession, Object) line: 1015<br />
+ DefaultIoFilterChain.callNextMessageReceived(IoFilterChain$Entry, IoSession, Object) line: 650<br />
+ DefaultIoFilterChain.access$1300(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, Object) line: 49
+ DefaultIoFilterChain$EntryImpl$1.messageReceived(IoSession, Object) line: 1128<br />
+ LoggingFilter.messageReceived(IoFilter$NextFilter, IoSession, Object) line: 208
+ DefaultIoFilterChain.callNextMessageReceived(IoFilterChain$Entry, IoSession, Object) line: 650<br />
+ DefaultIoFilterChain.access$1300(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, Object) line: 49
+ DefaultIoFilterChain$EntryImpl$1.messageReceived(IoSession, Object) line: 1128<br />
+ ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(IoFilter$NextFilter, IoSession) line: 413
+ ProtocolCodecFilter.messageReceived(IoFilter$NextFilter, IoSession, Object) line: 257
+ DefaultIoFilterChain.callNextMessageReceived(IoFilterChain$Entry, IoSession, Object) line: 650<br />
+ DefaultIoFilterChain.access$1300(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, Object) line: 49
+ DefaultIoFilterChain$EntryImpl$1.messageReceived(IoSession, Object) line: 1128<br />
+ CompressionFilter.messageReceived(IoFilter$NextFilter, IoSession, Object) line: 169
+ DefaultIoFilterChain.callNextMessageReceived(IoFilterChain$Entry, IoSession, Object) line: 650<br />
+ DefaultIoFilterChain.access$1300(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, Object) line: 49
+ DefaultIoFilterChain$EntryImpl$1.messageReceived(IoSession, Object) line: 1128<br />
+ SslHandler.flushScheduledEvents() line: 335
+ SslFilter.messageReceived(IoFilter$NextFilter, IoSession, Object) line: 553
+ DefaultIoFilterChain.callNextMessageReceived(IoFilterChain$Entry, IoSession, Object) line: 650<br />
+ DefaultIoFilterChain.access$1300(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, Object) line: 49
+ DefaultIoFilterChain$EntryImpl$1.messageReceived(IoSession, Object) line: 1128<br />
+ IoFilterEvent.fire() line: 105<br />
+ MdcInjectionFilter.filter(IoFilterEvent) line: 162<br />
+ MdcInjectionFilter(CommonEventFilter).messageReceived(IoFilter$NextFilter, IoSession, Object) line: 84<br />
+ DefaultIoFilterChain.callNextMessageReceived(IoFilterChain$Entry, IoSession, Object) line: 650<br />
+ DefaultIoFilterChain.access$1300(DefaultIoFilterChain, IoFilterChain$Entry, IoSession, Object) line: 49
+ DefaultIoFilterChain$EntryImpl$1.messageReceived(IoSession, Object) line: 1128<br />
+ DefaultIoFilterChain$HeadFilter(IoFilterAdapter).messageReceived(IoFilter$NextFilter, IoSession, Object) line: 122<br />
+ DefaultIoFilterChain.callNextMessageReceived(IoFilterChain$Entry, IoSession, Object) line: 650<br />
+ DefaultIoFilterChain.fireMessageReceived(Object) line: 643<br />
+ NioProcessor(AbstractPollingIoProcessor<S>).read(S) line: 539
+ AbstractPollingIoProcessor<S>.access$1200(AbstractPollingIoProcessor, AbstractIoSession) line: 68
+ AbstractPollingIoProcessor$Processor.process(S) line: 1223<br />
+ AbstractPollingIoProcessor$Processor.process() line: 1212
+ AbstractPollingIoProcessor$Processor.run() line: 683<br />
+ NamePreservingRunnable.run() line: 64
+ ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1149<br />
+ ThreadPoolExecutor$Worker.run() line: 624
+ Thread.run() line: 748 </p>
+<p>Writing the data is done when we are back in the AbstractPollingIoProcessor$Processor.run() call. Here is the stack for that action :</p>
+<p>::: text
+ NioProcessor.write(NioSession, IoBuffer, int) line: 384
+ NioProcessor.write(AbstractIoSession, IoBuffer, int) line: 47
+ AbstractPollingIoProcessor$Processor.writeBuffer(S, WriteRequest, boolean, int, long) line: 1107<br />
+ AbstractPollingIoProcessor$Processor.flushNow(S, long) line: 994<br />
+ AbstractPollingIoProcessor$Processor.flush(long) line: 921<br />
+ AbstractPollingIoProcessor$Processor.run() line: 688<br />
+ NamePreservingRunnable.run() line: 64
+ ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1149<br />
+ ThreadPoolExecutor$Worker.run() line: 624
+ Thread.run() line: 748 </p>
+<h2 id="the-sslfilter-implementation">The SslFilter implementation<a class="headerlink" href="#the-sslfilter-implementation" title="Permanent link">¶</a></h2>
+<p>As we can see,the <em>SslFilter</em> never calls the next filter. It delegates that to the <em>SslHandler</em> class. The trick is that it uses a queue to store encrypted messages, which will wait until the message is fully encrypted before flushing them. The rational is that a message can be pretty big, and teh <strong>SSL/TLS</strong> protocol just allows limited encrypted data blocks (around 16k), so it keeps each block of encrypted data into the queue temporarily.</p>
+<h1 id="room-for-improvements">Room for improvements<a class="headerlink" href="#room-for-improvements" title="Permanent link">¶</a></h1>
+<h2 id="reducing-the-stack-size">Reducing the stack size<a class="headerlink" href="#reducing-the-stack-size" title="Permanent link">¶</a></h2>
+<p>This is clearly sub-optimal. First of all, the stack is crazy big, there is no reason for that. The idea was intially to allow a session to dynamically update the chain, by adding or removing a filter while a session is active. This is a fine idea, as some protocols need to do that: typically, LDAP allows a user to send a <em>startTls</em> extended request which tells the server to establish a secured communication. In this very case, we add the <em>SslFilter</em> in the session's filter chain.</p>
+<p>Now, we can do that more efficiently. A session's filter chain is created when the session itself is created. Adding a new filter in this chain is done by the application, and at this point, no other thread uses this session (each session is associated with one single <em>IoProcessor</em> instance's thread), unless an <em>ExecutorFilter</em> has been added to the chain. In this case, things get complicated... Having an <em>ExecutorFilter</em> in the chain means any event can be processed concurrently, in different threads. Although they are sharing the same filter chain. We have to protect this chain against concurrent modifications, and we must also guarantee that any change made in the chain will not be an issue for the application.
+Typically, adding a <em>SslFilter</em> in a chain while a message is being written is problematic:
+<em> we have to wait for any pending messages to be sent to the remote peer, which may have already initiated a handshake (although it's the client responsability to handle this situation), or we decide to dicth any of those messages (the right thing to do, IMHO)
+</em> we have to deal with any message that are somewhere in the chain before the <em>SslFilter</em>. Again, the strategy would be to discard them
+* and we have to deal with any message somwhere in the chain after the <em>SslFilter</em> and before they are pushed into the session write queue, for the exact same reason.</p>
+<p>For messages received <em>before</em> the addition of the <em>SslFilter</em>, but still in the chain, we should ditch them for the exact same reason.</p>
+<p>Bottom line, this is a application issue, and should be handled by the application, because <strong>MINA</strong> can't deal with all the possible. starties in place of the application.</p>
+<p>That being said, we can use the <em>IoProcessor</em> as a controller. It would b eits responsability to propagate events from one filter to the other, using such a loop:</p>
+<p>::: text
+ for each filter in the chain
+ do
+ propagate the event to the filter with the previous result
+ store the result
+ done</p>
+<p>What we call the 'result' is just the transformed data. Typically, when calling the <em>ProtocolCodecFilter.messageReceived</em> event, the result will be the decoded message, not the <em>IoBuffer</em> (or whatever) input. This will be passed to the next filter (remember that the <em>IoFilter.messageReceived</em> method takes an <em>Object</em> as a parameter).</p>
+
+
+
+ </div><!-- rightColumn -->
+ <div id="endContent"></div>
+ </div><!-- content -->
+ <div id="footer">© 2003-2019, <a href="https://www.apache.org">The Apache Software Foundation</a> - <a href="./../../privacy-policy.html">Privacy Policy</a><br />
+ Apache MINA, MINA, Apache Vysper, Vysper, Apache SSHd, SSHd, Apache FtpServer, FtpServer, Apache AsyncWeb, AsyncWeb,
+ Apache, the Apache feather logo, and the Apache Mina project logos are trademarks of The Apache Software Foundation.
+ </div>
+ </div><!-- container -->
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-11074178-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+ </body>
+</html>
+
Added: websites/staging/mina/trunk/content/mina-project/technical-documentation/ssl-tls-internal.html
==============================================================================
--- websites/staging/mina/trunk/content/mina-project/technical-documentation/ssl-tls-internal.html (added)
+++ websites/staging/mina/trunk/content/mina-project/technical-documentation/ssl-tls-internal.html Wed Apr 3 10:33:52 2019
@@ -0,0 +1,224 @@
+<!DOCTYPE html>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+ <title>SSL/TLS internals — Apache MINA</title>
+
+ <link href="./../../css/common.css" rel="stylesheet" type="text/css">
+ <link href="./../../css/mina.css" rel="stylesheet" type="text/css">
+
+
+ <link rel="shortcut icon" href="./../../staticresources/images/mina-icon_16x16.png"/>
+
+</head>
+ <body>
+ <div id="container">
+ <div id="header">
+ <div id="subProjectsNavBar">
+ <a href="./../../">
+
+ Apache MINA Project
+
+ </a>
+ |
+ <a href="./../../mina-project/index.html">
+
+ <strong>MINA</strong>
+
+ </a>
+ |
+ <a href="./../../asyncweb-project/index.html">
+
+ AsyncWeb
+
+ </a>
+ |
+ <a href="./../../ftpserver-project/index.html">
+
+ FtpServer
+
+ </a>
+ |
+ <a href="./../../sshd-project/index.html">
+
+ SSHD
+
+ </a>
+ |
+ <a href="./../../vysper-project/index.html">
+
+ Vysper
+
+ </a>
+ </div><!-- subProjectsNavBar -->
+ </div><!-- header -->
+ <div id="content">
+ <div id="leftColumn">
+
+
+
+
+
+ <style type="text/css">
+/* The following code is added by mdx_elementid.py
+ It was originally lifted from http://subversion.apache.org/style/site.css */
+/*
+ * Hide class="elementid-permalink", except when an enclosing heading
+ * has the :hover property.
+ */
+.headerlink, .elementid-permalink {
+ visibility: hidden;
+}
+h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
+<div id="navigation">
+
+ <h5>Latest Downloads</h5>
+ <ul>
+ <li><a href="./../../mina-project/downloads_2_0.html">Mina 2.0.20</a></li>
+ <li><a href="./../../mina-project/downloads_2_1.html">Mina 2.1.0</a></li>
+ <li><a href="./../../mina-project/downloads_old.html">Mina old versions</a></li>
+ </ul>
+ <h5>Documentation</h5>
+ <ul>
+ <li><a href="./../../mina-project/documentation.html" class="external-link" rel="nofollow">Base documentation</a></li>
+ <li><a href="./../../mina-project/userguide/user-guide-toc.html" class="external-link" rel="nofollow">User guide</a></li>
+ <li><a href="./../../mina-project/2.1-vs-2.0.html" class="external-link" rel="nofollow">2.1 vs 2.0</a></li>
+ <li><a href="./../../mina-project/features.html" class="external-link" rel="nofollow">Features</a></li>
+ <li><a href="./../../mina-project/road-map.html" class="external-link" rel="nofollow">Road Map</a></li>
+ <li><a href="./../../mina-project/quick-start-guide.html" class="external-link" rel="nofollow">Quick Start Guide</a></li>
+ <li><a href="./../../mina-project/faq.html" class="external-link" rel="nofollow">FAQ</a></li>
+ </ul>
+ <h5>Resources</h5>
+ <ul>
+ <li><a href="./../../mina-project/mailing-lists.html" class="external-link" rel="nofollow">Mailing lists & IRC</a></li>
+ <li><a href="./../../mina-project/issue-tracking.html" class="external-link" rel="nofollow">Issue tracking</a></li>
+ <li><a href="./../../mina-project/sources.html" class="external-link" rel="nofollow">Sources</a></li>
+ <li><a href="./../../mina-project/gen-docs/latest-2.0/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.0.20</a></li>
+ <li><a href="./../../mina-project/gen-docs/latest-2.1/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.1.0</a></li>
+ <li><a href="./../../mina-project/gen-docs/latest-2.0/xref/index.html" class="external-link" rel="nofollow">API xref 2.0.20</a></li>
+ <li><a href="./../../mina-project/gen-docs/latest-2.1/xref/index.html" class="external-link" rel="nofollow">API xref 2.1.0</a></li>
+ <li><a href="./../../mina-project/performances.html" class="external-link" rel="nofollow">Performances</a></li>
+ <li><a href="./../../mina-project/testimonials.html" class="external-link" rel="nofollow">Testimonials</a></li>
+ <li><a href="./../../mina-project/conferences.html" class="external-link" rel="nofollow">Conferences</a></li>
+ <li><a href="./../../mina-project/developer-guide.html" class="external-link" rel="nofollow">Developers Guide</a></li>
+ <li><a href="./../../mina-project/related-projects.html" class="external-link" rel="nofollow">Related Projects</a></li>
+ <li><a href="https://people.apache.org/~vgritsenko/stats/projects/mina.html" class="external-link" rel="nofollow">Statistics</a></li>
+ </ul>
+
+
+ <h5>Community</h5>
+ <ul>
+ <li><a href="https://www.apache.org/foundation/contributing.html" class="external-link" rel="nofollow">Contributing</a></li>
+ <li><a href="./../../contributors.html" class="external-link" rel="nofollow">Team</a></li>
+ <li><a href="./../../special-thanks.html" class="external-link" rel="nofollow">Special Thanks</a></li>
+ <li><a href="https://www.apache.org/security/" class="external-link" rel="nofollow">Security</a></li>
+ </ul>
+
+
+ <h5>About Apache</h5>
+ <ul>
+ <li><a href="https://www.apache.org" class="external-link" rel="nofollow">Apache main site</a></li>
+ <li><a href="https://www.apache.org/licenses/" class="external-link" rel="nofollow">License</a></li>
+ <li><a href="https://www.apache.org/foundation/sponsorship.html" title="The ASF sponsorship program" class="external-link" rel="nofollow">Sponsorship program</a></li>
+ <li><a href="https://www.apache.org/foundation/thanks.html" class="external-link" rel="nofollow">Thanks</a></li>
+ </ul>
+
+
+ <h3><a name="Navigation-Upcoming"></a>Upcoming</h3>
+ <ul>
+ <li>No event</li>
+ </ul>
+
+</div>
+
+<!-- navigation -->
+
+
+ </div><!-- leftColumn -->
+ <div id="rightColumn">
+
+
+
+
+<style type="text/css">
+/* The following code is added by mdx_elementid.py
+ It was originally lifted from http://subversion.apache.org/style/site.css */
+/*
+ * Hide class="elementid-permalink", except when an enclosing heading
+ * has the :hover property.
+ */
+.headerlink, .elementid-permalink {
+ visibility: hidden;
+}
+h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
+<h1 id="ssltls-internals">SSL/TLS internals<a class="headerlink" href="#ssltls-internals" title="Permanent link">¶</a></h1>
+<p>This is a technical description of how SSL/TLS are handled in MINA. You don't need to read this to have it working, better have a look at the <a href="../userguide/ch11-ss-filter/ch11-ssl-filter.html">SslFilter user guide</a> page. However, if you want to get a deeper understanding on how it's built, this is the place !</p>
+<h2 id="components">Components<a class="headerlink" href="#components" title="Permanent link">¶</a></h2>
+<p>The <strong>SslFilter</strong> is the filter that command everything related to <strong>SSL/TLS</strong>. It works hands in hands with the <strong>SSLHandler</strong> class, which handles the logic.</p>
+<p>With <strong>NIO</strong>, Java provides a special class that handles the <strong>SSL/TLS</strong> protocol, the <strong>SSLEngine</strong> class. It's quite a complex piece of code, and it requires some time to tame it... We will have a look into it during this tutotial.</p>
+<h2 id="creation">Creation<a class="headerlink" href="#creation" title="Permanent link">¶</a></h2>
+<p>In order to inject the filter in the chain, it must first be created. This filter takes one or two parameters:
+<em> <strong>SSLContext</strong>: the Java class that contains all the information related to the <strong>SSL/TLS</strong> establishment
+</em> <strong>autoStart</strong>: tells if the handshake should be started immediately. This is an optional parameter, defaulting to <strong>TRUE</strong>. In some cases, like when using <strong>startTLS</strong>, it's critical to not start the handshake immediately, as it will be established on demand.</p>
+<h2 id="initialization">Initialization<a class="headerlink" href="#initialization" title="Permanent link">¶</a></h2>
+<p>When injecting the <strong>SslFilter</strong> into your chain, either before starting your service, or while running it, it has to be initialized in some way. Actually, this is a two phases process :
+- pre-initialization, during the filter injection
+- post-initialization, by starting the Handshake dialog</p>
+<p>Most of the time, both phases will be merged, as one can tell the first phase to immediately starts the second.</p>
+<p>In any case, it's handled by the <strong>onPreAdd</strong> and __onPostAdd_ events, which means it's automatically processed when you push the <strong>SslFilter</strong> into the chain.</p>
+<h3 id="onpreadd">onPreAdd<a class="headerlink" href="#onpreadd" title="Permanent link">¶</a></h3>
+<p>The <strong>SslHandler</strong> class is created and initialized, and the instance is stored into the session attributes. That means each session has its own instance of <strong>SslHandler</strong>. This initialization will create a <strong>SSLEngine</strong> instance based on the provided <strong>SSLContext</strong> instance. The initialization will differ based on the 'side' you are on: server or client. Basically, the server side will wait for the client to initiate the handshake, while the client side will intitiate it.</p>
+<p>It's also responsible to set the enabled ciphers and protocols, if one wants to use a restricted set, or an extended set (newer versions of Java have disabled old protocols and insecured ciphers).</p>
+<p>Last, not least, it sets a list of status flags :
+<em> writingEncryptedData: false. This flag is used during the handshake
+</em> handshakeStatus: the HandShake status, which is originally set to <strong>NOT_HANDSHAKING</strong>
+<em> firstSSLNegociation: true. This flag is used to tell the <strong>sslHandler</strong> to send or not an event to the application (MINA 2.1 only)
+</em> handshakeComplete: false. It will be set to true when teh handshake has been completed.</p>
+<p>Side note: those flags are probably spurious. Some cleanup might be done to get rid of the useless ones.</p>
+<h2 id="onpostadd">onPostAdd<a class="headerlink" href="#onpostadd" title="Permanent link">¶</a></h2>
+<p>This event will initiate an immediate handshake if required. Depending on the perr side, the action will be different.</p>
+<ul>
+<li>if we are on the server peer</li>
+</ul>
+
+
+
+ </div><!-- rightColumn -->
+ <div id="endContent"></div>
+ </div><!-- content -->
+ <div id="footer">© 2003-2019, <a href="https://www.apache.org">The Apache Software Foundation</a> - <a href="./../../privacy-policy.html">Privacy Policy</a><br />
+ Apache MINA, MINA, Apache Vysper, Vysper, Apache SSHd, SSHd, Apache FtpServer, FtpServer, Apache AsyncWeb, AsyncWeb,
+ Apache, the Apache feather logo, and the Apache Mina project logos are trademarks of The Apache Software Foundation.
+ </div>
+ </div><!-- container -->
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-11074178-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+ </body>
+</html>
+
Modified: websites/staging/mina/trunk/content/mina-project/userguide/ch11-ssl-filter/ch11-ssl-filter.html
==============================================================================
--- websites/staging/mina/trunk/content/mina-project/userguide/ch11-ssl-filter/ch11-ssl-filter.html (original)
+++ websites/staging/mina/trunk/content/mina-project/userguide/ch11-ssl-filter/ch11-ssl-filter.html Wed Apr 3 10:33:52 2019
@@ -221,13 +221,13 @@ Actually, <strong>TLS</strong> is suppos
<p>This is up to you to provide the <strong>KeyManager</strong>, <strong>TrustManager</strong> and <strong>SecureRandom</strong> instances.</p>
-<p>be sure to inject the <strong>SslFilter</strong> on the first position in your chain !</p>
+<p>Be sure to inject the <strong>SslFilter</strong> on the first position in your chain !</p>
<p>We will see later a detailed exemple on how to create a <strong>SSLContext</strong>.</p>
<h2 id="a-bit-of-theory">A bit of theory<a class="headerlink" href="#a-bit-of-theory" title="Permanent link">¶</a></h2>
<p>If you want to get a deeper understanding on how it all works, please read the following paragraphs...</p>
<h3 id="ssl-basics">SSL Basics<a class="headerlink" href="#ssl-basics" title="Permanent link">¶</a></h3>
<p>We are not going to explain how <strong>SSL</strong> works, there are very <a href="http://www.amazon.com/SSL-TLS-Designing-Building-Systems/dp/0201615983">good books</a> outhere. We will just give a quick introduction on how it works and how it is implemented in MINA.</p>
-<p>First of all, you have to understand that <strong>SSL/TLS</strong> is a protocol defined in <strong>RFCs</strong> : <a href="https://www.rfc-editor.org/rfc/rfc2246.txt">TLS 1.0</a>, <a href="https://www.rfc-editor.org/rfc/rfc4346.txt">TLS 1.1</a> and <a href="https://www.rfc-editor.org/rfc/rfc5246.txt">TLS 1.2</a>. There is a <a href="https://tlswg.github.io/tls13-spec/">TLS 1.3</a> draft being worked on...</p>
+<p>First of all, you have to understand that <strong>SSL/TLS</strong> is a protocol defined in <strong>RFCs</strong> : <a href="https://www.rfc-editor.org/rfc/rfc2246.txt">TLS 1.0</a>, <a href="https://www.rfc-editor.org/rfc/rfc4346.txt">TLS 1.1</a>, <a href="https://www.rfc-editor.org/rfc/rfc5246.txt">TLS 1.2</a> and <a href="https://tools.ietf.org/html/rfc8446">RLS 1.3</a>.</p>
<p>It was initially developed by <strong>Netscape</strong>, and named <strong>SSL</strong> (from 1.0 to 3.0), before becoming <strong>TLS</strong>. Nowadays, <strong><em>SSL 2.0</em>* and </strong>SSL 3.0** have been deprecated and should not be used.</p>
<h3 id="the-ssltls-protocol">The SSL/TLS protocol<a class="headerlink" href="#the-ssltls-protocol" title="Permanent link">¶</a></h3>
<p>As it's a protocol, it requires some dialog between a client and a server. This is all what <strong>SSL/TLS</strong> is about : describing this dialog. </p>
@@ -237,8 +237,9 @@ Actually, <strong>TLS</strong> is suppos
</DIV>
<p>As you can see in this picture, it's a 2 phases protocol : first the handshake, then when completed the client and the server will be able to exchange data that will be encrypted.</p>
+<p>There are also other phases, like the <strong>SSL/TLS</strong> closure, or a renegociation phase.</p>
<h4 id="the-handshake">The Handshake<a class="headerlink" href="#the-handshake" title="Permanent link">¶</a></h4>
-<p>Basically, it's all about negociating many elements that are to be used to encrypt the data. The details are not so interesting in the context of this document, enough said that many messages are going to be exchanged between the client and the server, and no data can be sent during this phase. </p>
+<p>Basically, it's all about negociating many elements that are to be used to encrypt/decrypt the data. The details are not so interesting in the context of this document, enough said that many messages are going to be exchanged between the client and the server, and no data can be sent during this phase. </p>
<p>Actually, there are two conditions for the handshake to start :
<em> The server must be waiting for some handshake message to arrive
</em> The client must send a <strong>ClientHello</strong> message</p>