<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div class="">Hi,</div>
<div class=""><br class="">
</div>
I created pull request to reorder SNI/ALPN processing, such that ALPN occurs after SNI. Since SNI may change the SSL_CTX, and the ALPN callback is defined on the SSL_CTX, it makes sense to allow SNI to possibly update the SSL_CTX, and then do ALPN processing
 (possibly for a new virtual server).
<div class=""><br class="">
</div>
<div class=""><a href="https://github.com/openssl/openssl/pull/787" class="">https://github.com/openssl/openssl/pull/787</a><br class="">
<div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div class="">--</div>
<div class="">-Todd Short</div>
<div class="">// tshort@akamai.com</div>
<div class="">// "One if by land, two if by sea, three if by the Internet."</div>
</div>
</div>
</div>
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Mar 3, 2016, at 2:33 PM, Short, Todd <tshort@akamai.com> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">We’ve run into an issue with the ALPN and SNI TLS extension callbacks in 1.0.2. The same behavior may be in master, but I have yet to check.<br class="">
<br class="">
In summary, the ALPN selection callback is invoked before the SNI/servername callback, yet the ALPN value returned may be dependent on the server being connected to. In other words, ALPN may be broken for virtual servers.<br class="">
<br class="">
There’s a comment in ssl_parse_clienthello_tlsext() that clearly states:<br class="">
<br class="">
   /*<br class="">
    * Internally supported extensions are parsed first so SNI can be handled<br class="">
    * before custom extensions. An application processing SNI will typically<br class="">
    * switch the parent context using SSL_set_SSL_CTX and custom extensions<br class="">
    * need to be handled by the new SSL_CTX structure.<br class="">
    */<br class="">
<br class="">
There are 4 functions that handle TLS extensions, and are invoked in the following order<br class="">
<br class="">
ssl_scan_clienthello_tlsext()<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* saves servername<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* saves ec_point_formats<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* saves elliptic_curve list<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* saves opaque PRF input<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* calls session ticket callback<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* saves status request<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* saves heartbeat<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* notes NPN seen<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* calls ALPN callback<br class="">
<br class="">
ssl_check_clienthello_tlsext_early()<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* calls servername callback<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* calls PRF callback<br class="">
<br class="">
ssl_scan_clienthello_custom_tlsext()<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* parses custom extensions<br class="">
<br class="">
ssl_check_clienthello_tlsext_late()<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* calls status callback<br class="">
<br class="">
I would argue that ALPN data should be saved in ssl_scan_clienthello_tlsext() and processed in ssl_check_clienthello_tlsext_early() - after the servername callback<br class="">
<br class="">
--<br class="">
-Todd Short<br class="">
// tshort@akamai.com<br class="">
// "One if by land, two if by sea, three if by the Internet."<br class="">
<br class="">
-- <br class="">
openssl-dev mailing list<br class="">
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>