aboutsummaryrefslogtreecommitdiff
path: root/test.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2013-11-16 20:21:48 -0800
committerSteven Fackler <[email protected]>2013-11-16 20:21:48 -0800
commitf8be6415366927350c8874a4c3dc542622979408 (patch)
tree2fef68adce0abae0fca4de4b8cb205a7d7448095 /test.rs
parentSwitch docs to sfackler.com (diff)
downloadrust-openssl-f8be6415366927350c8874a4c3dc542622979408.tar.xz
rust-openssl-f8be6415366927350c8874a4c3dc542622979408.zip
Start of x509 interface
Diffstat (limited to 'test.rs')
-rw-r--r--test.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/test.rs b/test.rs
index 4167f9eb..cc9e8bab 100644
--- a/test.rs
+++ b/test.rs
@@ -4,7 +4,7 @@ use std::io::Writer;
use std::io::net::tcp::TcpStream;
use std::str;
-use lib::{Sslv23, SslContext, SslStream, SslVerifyPeer};
+use lib::{Sslv23, SslContext, SslStream, SslVerifyPeer, X509StoreContext};
mod lib;
@@ -47,7 +47,7 @@ fn test_verify_trusted() {
#[test]
fn test_verify_untrusted_callback_override_ok() {
- fn callback(_preverify_ok: bool) -> bool {
+ fn callback(_preverify_ok: bool, _x509_ctx: X509StoreContext) -> bool {
true
}
let stream = TcpStream::connect(FromStr::from_str("127.0.0.1:15418").unwrap()).unwrap();
@@ -61,7 +61,7 @@ fn test_verify_untrusted_callback_override_ok() {
#[test]
fn test_verify_untrusted_callback_override_bad() {
- fn callback(_preverify_ok: bool) -> bool {
+ fn callback(_preverify_ok: bool, _x509_ctx: X509StoreContext) -> bool {
false
}
let stream = TcpStream::connect(FromStr::from_str("127.0.0.1:15418").unwrap()).unwrap();
@@ -72,7 +72,7 @@ fn test_verify_untrusted_callback_override_bad() {
#[test]
fn test_verify_trusted_callback_override_ok() {
- fn callback(_preverify_ok: bool) -> bool {
+ fn callback(_preverify_ok: bool, _x509_ctx: X509StoreContext) -> bool {
true
}
let stream = TcpStream::connect(FromStr::from_str("127.0.0.1:15418").unwrap()).unwrap();
@@ -90,7 +90,7 @@ fn test_verify_trusted_callback_override_ok() {
#[test]
fn test_verify_trusted_callback_override_bad() {
- fn callback(_preverify_ok: bool) -> bool {
+ fn callback(_preverify_ok: bool, _x509_ctx: X509StoreContext) -> bool {
false
}
let stream = TcpStream::connect(FromStr::from_str("127.0.0.1:15418").unwrap()).unwrap();
@@ -104,6 +104,18 @@ fn test_verify_trusted_callback_override_bad() {
}
#[test]
+fn test_verify_callback_load_certs() {
+ fn callback(_preverify_ok: bool, x509_ctx: X509StoreContext) -> bool {
+ assert!(x509_ctx.get_current_cert().is_some());
+ true
+ }
+ let stream = TcpStream::connect(FromStr::from_str("127.0.0.1:15418").unwrap()).unwrap();
+ let mut ctx = SslContext::new(Sslv23);
+ ctx.set_verify(SslVerifyPeer, Some(callback));
+ assert!(SslStream::try_new(&ctx, stream).is_ok());
+}
+
+#[test]
fn test_write() {
let stream = TcpStream::connect(FromStr::from_str("127.0.0.1:15418").unwrap()).unwrap();
let mut stream = SslStream::new(&SslContext::new(Sslv23), stream);