Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ecf8487438b2
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2f7ad67fd67c
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Jun 24, 2016

  1. OpenSSL: get selected ALPN protocol

    ysbaddaden authored and jhass committed Jun 24, 2016
    Copy the full SHA
    97011f3 View commit details
  2. Merge branch 'release/0.18'

    jhass committed Jun 24, 2016
    Copy the full SHA
    2f7ad67 View commit details
Showing with 10 additions and 0 deletions.
  1. +1 −0 src/openssl/lib_ssl.cr
  2. +9 −0 src/openssl/ssl/socket.cr
1 change: 1 addition & 0 deletions src/openssl/lib_ssl.cr
Original file line number Diff line number Diff line change
@@ -182,6 +182,7 @@ lib LibSSL
alias X509VerifyParam = LibCrypto::X509VerifyParam

fun ssl_get0_param = SSL_get0_param(handle : SSL) : X509VerifyParam
fun ssl_get0_alpn_selected = SSL_get0_alpn_selected(handle : SSL, data : Char**, len : LibC::UInt*) : Void
fun ssl_ctx_set_alpn_select_cb = SSL_CTX_set_alpn_select_cb(ctx : SSLContext, cb : ALPNCallback, arg : Void*) : Void
fun ssl_ctx_get0_param = SSL_CTX_get0_param(ctx : SSLContext) : X509VerifyParam
fun ssl_ctx_set1_param = SSL_CTX_set1_param(ctx : SSLContext, param : X509VerifyParam) : Int
9 changes: 9 additions & 0 deletions src/openssl/ssl/socket.cr
Original file line number Diff line number Diff line change
@@ -117,6 +117,15 @@ abstract class OpenSSL::SSL::Socket
@bio.io.flush
end

{% if LibSSL::OPENSSL_102 %}
# Returns the negotiated ALPN protocol (eg: "h2") of nil if no protocol was
# negotiated.
def alpn_protocol
LibSSL.ssl_get0_alpn_selected(@ssl, out protocol, out len)
String.new(protocol, len) unless protocol.null?
end
{% end %}

def close
return if @closed
@closed = true