Commit 11059e1b authored by Steven Fackler's avatar Steven Fackler
Browse files

Merge pull request #179 from manuels/dtls

DTLS support
parents 51dd1293 637e981e
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -5,13 +5,25 @@ os:
env:
  global:
  - secure: J4i75AV4KMrU/UQrLIzzIh35Xix40Ki0uWjm8j05oxlXVl5aPU2zB30AemDne2QXYzkN4kRG/iRnNORE/8D0lF7YipQNSNxgfiBVoOEfj/NSogvI2BftYX9vlLZJUvt+s/nbE3xa/Pyge1IPv7itDYGO7SMe8RTSqitgqyfE2Eg=
  - FEATURES="tlsv1_1 tlsv1_2 aes_xts npn"
  - FEATURES="tlsv1_1 tlsv1_2 dtlsv1 aes_xts npn"
before_install:
  - DIR=`pwd`
  - (test $TRAVIS_OS_NAME == "osx" || (sudo apt-get install gcc make))
  - (test $TRAVIS_OS_NAME == "osx" || (wget https://openssl.org/source/openssl-1.0.2-latest.tar.gz -O /tmp/openssl-1.0.2-latest.tar.gz))
  - (test $TRAVIS_OS_NAME == "osx" || (cd /tmp && tar xzf openssl-1.0.2-latest.tar.gz))
  - (test $TRAVIS_OS_NAME == "osx" || (cd /tmp/openssl-1.0.2*/ && ./config --prefix=/usr/ shared))
  - (test $TRAVIS_OS_NAME == "osx" || (cd /tmp/openssl-1.0.2*/ && make))
  - (test $TRAVIS_OS_NAME == "osx" || (cd /tmp/openssl-1.0.2*/ && sudo make install))
  - cd ${DIR}
before_script:
  - openssl version
  - openssl s_server -accept 15418 -www -cert openssl/test/cert.pem -key openssl/test/key.pem >/dev/null 2>&1 &
  - openssl s_server -accept 15419 -www -cert openssl/test/cert.pem -key openssl/test/key.pem -nextprotoneg "http/1.1,spdy/3.1" >/dev/null 2>&1 &
script:
- (cd openssl && cargo test)
- (test $TRAVIS_OS_NAME == "osx" || (cd openssl && cargo test --features "$FEATURES"))
- (cd openssl && LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH cargo test)
- (test $TRAVIS_OS_NAME == "osx" || (./openssl/test/test.sh &))
- (test $TRAVIS_OS_NAME == "osx" || (cd openssl && LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH cargo test --features "$FEATURES"))
- (test $TRAVIS_OS_NAME == "osx" || killall openssl)
- ./.travis/build_docs.sh
after_success:
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && ./.travis/update_docs.sh
+4 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ rust-openssl directory. Then run one of the following commands:

* Windows: `openssl s_server -accept 15418 -www -cert test/cert.pem -key
  test/key.pem > NUL`
* Linux: `openssl s_server -accept 15418 -www -cert test/cert.pem -key
* Linux: `openssl s_server -accept 15418 -www -cert test/cert.pem -key \
  test/key.pem >/dev/null`

Then in the original terminal, run `cargo test`. If everything is set up
@@ -71,4 +71,7 @@ correctly, all tests should pass. You might get some warnings in the `openssl
s_server` window. Those aren't anything to worry about. You can stop the server
using Control-C.

For DTLS testing each test requires its own instance of OpenSSL's s_server. On
Linux you can run the bash script in `openssl/tests/test.sh`.

[1]: http://slproweb.com/products/Win32OpenSSL.html
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ build = "build.rs"
[features]
tlsv1_2 = []
tlsv1_1 = []
dtlsv1 = []
dtlsv1_2 = []
sslv2 = []
aes_xts = []
npn = []
+8 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77;
pub const SSL_CTRL_SET_TLSEXT_HOSTNAME: c_int = 55;
pub const SSL_CTRL_EXTRA_CHAIN_CERT: c_int = 14;

pub const SSL_CTRL_SET_READ_AHEAD: c_int = 41;
pub const SSL_ERROR_NONE: c_int = 0;
pub const SSL_ERROR_SSL: c_int = 1;
pub const SSL_ERROR_SYSCALL: c_int = 5;
@@ -282,6 +283,9 @@ pub unsafe fn SSL_CTX_add_extra_chain_cert(ssl: *mut SSL_CTX, cert: *mut X509) -
    SSL_CTX_ctrl(ssl, SSL_CTRL_EXTRA_CHAIN_CERT, 0, cert)
}

pub unsafe fn SSL_CTX_set_read_ahead(ctx: *mut SSL_CTX, m: c_long) -> c_long {
    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_READ_AHEAD, m, ptr::null_mut())
}

// True functions
extern "C" {
@@ -482,6 +486,10 @@ extern "C" {
    pub fn TLSv1_1_method() -> *const SSL_METHOD;
    #[cfg(feature = "tlsv1_2")]
    pub fn TLSv1_2_method() -> *const SSL_METHOD;
    #[cfg(feature = "dtlsv1")]
    pub fn DTLSv1_method() -> *const SSL_METHOD;
    #[cfg(feature = "dtlsv1_2")]
    pub fn DTLSv1_2_method() -> *const SSL_METHOD;
    pub fn SSLv23_method() -> *const SSL_METHOD;

    pub fn SSL_new(ctx: *mut SSL_CTX) -> *mut SSL;
+6 −1
Original line number Diff line number Diff line
@@ -7,11 +7,13 @@ description = "OpenSSL bindings"
repository = "https://github.com/sfackler/rust-openssl"
documentation = "https://sfackler.github.io/rust-openssl/doc/openssl"
readme = "../README.md"
keywords = ["crypto", "tls", "ssl"]
keywords = ["crypto", "tls", "ssl", "dtls"]

[features]
tlsv1_2 = ["openssl-sys/tlsv1_2"]
tlsv1_1 = ["openssl-sys/tlsv1_1"]
dtlsv1 = ["openssl-sys/dtlsv1"]
dtlsv1_2 = ["openssl-sys/dtlsv1_2"]
sslv2 = ["openssl-sys/sslv2"]
aes_xts = ["openssl-sys/aes_xts"]
npn = ["openssl-sys/npn"]
@@ -27,3 +29,6 @@ libc = "0.1"

[dev-dependencies]
rustc-serialize = "0.3"

[dev-dependencies.connected_socket]
connected_socket = "0.0.1"
Loading