File: badssl.rs

package info (click to toggle)
rust-rustls 0.23.31%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 13,780 kB
  • sloc: sh: 199; python: 181; makefile: 11
file content (151 lines) | stat: -rw-r--r-- 3,797 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// These tests use the various test servers run by Google
// at badssl.com.

#[allow(dead_code)]
mod common;

mod online {
    use super::common::TlsClient;

    fn connect(hostname: &str) -> TlsClient {
        TlsClient::new(hostname)
    }

    #[test]
    #[ignore]
    fn no_cbc() {
        connect("cbc.badssl.com")
            .fails()
            .expect(r"TLS error: received fatal alert: HandshakeFailure")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn no_rc4() {
        connect("rc4.badssl.com")
            .fails()
            .expect(r"TLS error: received fatal alert: HandshakeFailure")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn expired() {
        connect("expired.badssl.com")
            .fails()
            .expect(r"TLS error: invalid peer certificate: certificate expired: verification time [0-9]+ \(UNIX\), but certificate is not valid after [0-9]+ \([0-9]+ seconds ago\)")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn wrong_host() {
        connect("wrong.host.badssl.com")
            .fails()
            .expect(r#"TLS error: invalid peer certificate: certificate not valid for name \"wrong.host.badssl.com\"; certificate is only valid for DnsName\(\"\*.badssl.com\"\) or DnsName\(\"badssl.com\"\)"#)
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn self_signed() {
        connect("self-signed.badssl.com")
            .fails()
            .expect(r"TLS error: invalid peer certificate: UnknownIssuer")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn no_dh() {
        connect("dh2048.badssl.com")
            .fails()
            .expect(r"TLS error: received fatal alert: HandshakeFailure")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn mozilla_old() {
        connect("mozilla-old.badssl.com")
            .expect("<title>mozilla-old.badssl.com</title>")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn mozilla_inter() {
        connect("mozilla-intermediate.badssl.com")
            .expect("<title>mozilla-intermediate.badssl.com</title>")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn mozilla_modern() {
        connect("mozilla-modern.badssl.com")
            .expect("<title>mozilla-modern.badssl.com</title>")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn sha256() {
        connect("sha256.badssl.com")
            .expect("<title>sha256.badssl.com</title>")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn too_many_sans() {
        connect("10000-sans.badssl.com")
            .fails()
            .expect(r"TLS error: received corrupt message of type HandshakePayloadTooLarge")
            .go()
            .unwrap();
    }

    #[ignore] // https://github.com/chromium/badssl.com/issues/530
    #[test]
    #[ignore]
    fn rsa8192() {
        connect("rsa8192.badssl.com")
            .expect("<title>rsa8192.badssl.com</title>")
            .go()
            .unwrap();
    }

    #[test]
    #[ignore]
    fn sha1_2016() {
        connect("sha1-2016.badssl.com")
            .fails()
            .expect(r"TLS error: invalid peer certificate: certificate expired: verification time [0-9]+ \(UNIX\), but certificate is not valid after [0-9]+ \([0-9]+ seconds ago\)")
            .go()
            .unwrap();
    }

    mod danger {
        #[test]
        #[ignore]
        fn self_signed() {
            super::connect("self-signed.badssl.com")
                .insecure()
                .expect("<title>self-signed.badssl.com</title>")
                .go()
                .unwrap();
        }
    }
}