<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                今天數據隱私是一個十分關注的問題,作為開發人員,我們需要準備好解決這個問題。至少我們需要熟悉加密協議 SSL 和 TLS 等之上的其他協議實現數據安全。作為一個 HTTPS 網站的用戶,你是安全。當然,這些協議是廣泛不基于 http 的應用程序,例如安全SMTP(SMTPS)郵件服務,甚至關系數據庫系統。 為了支持 SSL/TLS,Java 提供了 javax.net.ssl API 的類SslContext 和 SslEngine 使它相對簡單的實現解密和加密。Netty 的利用該 API 命名 SslHandler 的 ChannelHandler 實現, 有一個內部 SslEngine 做實際的工作。 圖8.1顯示了一個使用 SslHandler 數據流圖。 [![](https://box.kancloud.cn/2015-08-18_55d32230db409.jpg)](https://github.com/waylau/essential-netty-in-action/blob/master/images/Figure%208.1%20Data%20flow%20through%20SslHandler%20for%20decryption%20and%20encryption.jpg) 1. 加密的入站數據被 SslHandler 攔截,并被解密 2. 前面加密的數據被 SslHandler 解密 3. 平常數據傳過 SslHandler 4. SslHandler 加密數據并它傳遞出站 Figure 8.1 Data flow through SslHandler for decryption and encryption 如清單8.1所示一個 SslHandler 使用 ChannelInitializer 添加到 ChannelPipeline。(回想一下,當 Channel 注冊時 ChannelInitializer 用于設置 ChannelPipeline 。) Listing 8.1 Add SSL/TLS support ~~~ public class SslChannelInitializer extends ChannelInitializer<Channel> { private final SslContext context; private final boolean startTls; public SslChannelInitializer(SslContext context, boolean client, boolean startTls) { //1 this.context = context; this.startTls = startTls; } @Override protected void initChannel(Channel ch) throws Exception { SSLEngine engine = context.newEngine(ch.alloc()); //2 engine.setUseClientMode(client); //3 ch.pipeline().addFirst("ssl", new SslHandler(engine, startTls)); //4 } } ~~~ 1. 使用構造函數來傳遞 SSLContext 用于使用(startTls 是否啟用) 2. 從 SslContext 獲得一個新的 SslEngine 。給每個 SslHandler 實例使用一個新的 SslEngine 3. 設置 SslEngine 是 client 或者是 server 模式 4. 添加 SslHandler 到 pipeline 作為第一個處理器 在大多數情況下,SslHandler 將成為 ChannelPipeline 中的第一個 ChannelHandler 。這將確保所有其他 ChannelHandler 應用他們的邏輯到數據后加密后才發生,從而確保他們的變化是安全的。 SslHandler 有很多有用的方法,如表8.1所示。例如,在握手階段兩端相互驗證,商定一個加密方法。您可以配置 SslHandler 修改其行為或提供 在SSL/TLS 握手完成后發送通知,這樣所有數據都將被加密。 SSL/TLS 握手將自動執行。 Table 8.1 SslHandler methods | 名稱 | 描述 | | --- | --- | | setHandshakeTimeout(...) setHandshakeTimeoutMillis(...) getHandshakeTimeoutMillis() | | Set and get the timeout, after which the handshake ChannelFuture is notified of failure. setCloseNotifyTimeout(...) setCloseNotifyTimeoutMillis(...) getCloseNotifyTimeoutMillis() | Set and get the timeout after which the close notify will time out and the connection will close. This also results in having the close notify ChannelFuture fail. handshakeFuture() | Returns a ChannelFuture that will be notified once the handshake is complete. If the handshake was done before it will return a ChannelFuture that contains the result of the previous handshake. close(...) | Send the close_notify to request close and destroy the underlying SslEngine.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看