diff options
| author | Valerii Hiora <[email protected]> | 2014-10-07 15:09:20 +0300 |
|---|---|---|
| committer | Valerii Hiora <[email protected]> | 2014-10-07 19:58:52 +0300 |
| commit | 3ba768bc288031964994e39d0fa08607fccf728e (patch) | |
| tree | 65fefee9f35059aa0f33af627e57d0031236b422 /src/ssl | |
| parent | Merge pull request #69 from vhbit/bn-zero-fix (diff) | |
| download | rust-openssl-3ba768bc288031964994e39d0fa08607fccf728e.tar.xz rust-openssl-3ba768bc288031964994e39d0fa08607fccf728e.zip | |
Fixed incorrect EOF handling in MemBio, added error description
Actually, EOF wasn't handled at all and it caused `mem_bio.read_to_end()` to fail. Which in turn failed all `write_pem` implementations.
Diffstat (limited to 'src/ssl')
| -rw-r--r-- | src/ssl/tests.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ssl/tests.rs b/src/ssl/tests.rs index 50c24b94..1113b2df 100644 --- a/src/ssl/tests.rs +++ b/src/ssl/tests.rs @@ -1,4 +1,4 @@ -use std::io::Writer; +use std::io::{File, Open, Write, Writer}; use std::io::net::tcp::TcpStream; use std::num::FromStrRadix; use std::str; @@ -218,6 +218,22 @@ fn test_cert_gen() { let res = gen.generate(); assert!(res.is_ok()); + + let (cert, pkey) = res.unwrap(); + + #[cfg(unix)] + static NULL_PATH: &'static str = "/dev/null"; + #[cfg(windows)] + static NULL_PATH: &'static str = "nul"; + + let cert_path = Path::new(NULL_PATH); + let mut file = File::open_mode(&cert_path, Open, Write).unwrap(); + assert!(cert.write_pem(&mut file).is_ok()); + + let key_path = Path::new(NULL_PATH); + let mut file = File::open_mode(&key_path, Open, Write).unwrap(); + assert!(pkey.write_pem(&mut file).is_ok()); + // FIXME: check data in result to be correct, needs implementation // of X509 getters } |