]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - tcl_tests/client.try
tcl_tests: ca.try: Ignore openssl crl exit status for 'corrupted CRL' test
[openssl-gost/engine.git] / tcl_tests / client.try
1 #!/usr/bin/tclsh
2 lappend auto_path [file dirname [info script]]
3
4 package require ossltest
5
6 if {$argc != 1} {
7         puts stderr "Usage $argv0 cipher-list-file"
8         exit 1
9 }       
10
11 array set protos {
12         SSLv2 -ssl2
13         SSLv3 -ssl3
14         TLSv1 -tls1
15         TLSv1.1 -tls1_1
16         TLSv1.2 -tls1_2
17     "default" {}
18 }       
19 get_hosts [lindex $argv 0]
20 cd $::test::dir 
21 start_tests "TLS-соединение от клиента [lindex $argv 0]"
22
23 set CAhost lynx.lan.cryptocom.ru
24 set CAprefix /cgi-bin/autoca
25
26
27 foreach alg [array names hosts] {
28         set alg2 [regsub {(gost\d+)cp} $alg {\1}]
29         set alg_fn [string map {":" "_"} $alg2]
30         set alg_ca [regexp -inline {^[^:]+} $alg]
31         log "alg_fn=$alg_fn"
32         if {[string match gost2001* $alg]} {
33                 set alg_cli_list "gost2001_A gost2001_XA"
34         } elseif {[string match gost2012* $alg]} {
35                 set alg_cli_list "gost2001_A gost2012_256_A gost2012_256_XA gost2012_512_A gost2012_512_B"
36         } else {
37                 set alg_cli_list $alg_ca
38         }
39
40
41         test -skip {[file exist ca_$alg_ca.pem]} "Получить сертификат $alg_ca CA" {
42                 getCAcert $CAhost $CAprefix $alg_ca
43         } 0 "ca_$alg_ca.pem"
44
45         test -skip {[file exist srv_$alg_fn/cert.pem]} "Получить сертификат $alg для сервера" {
46                 getCAAlgParams $CAhost $CAprefix $alg_ca
47                 if {![makeUser srv_$alg_fn $alg2 CN [info hostname]]} {
48                         error "Request generation failed"
49                 }
50                 registerUserAtCA srv_$alg_fn $CAhost $CAprefix $alg_ca
51                 file exists srv_$alg_fn/cert.pem
52         } 0 1
53
54         if {[array exists suites]} {array unset suites}
55         array set suites $hosts($alg)
56         foreach suite [array names suites] {
57                 if {![regexp {(.+):(.+)} $suite => proto cs]} {
58                         set cs $suite
59                         set proto "default"
60                 }       
61                 if {[info exists suite_map($cs)]} {
62                         set mycs $suite_map($cs)
63                 } else {
64                         set mycs $cs
65                 }       
66                 set host [lindex [split $suites($suite) :] 0]
67                 set host_short [lindex [split $host .] 0]
68                 # We assume that CA certificates are already copied into Apache
69                 # cert dir
70                 set ca_file "/etc/apache/ssl.crt/${alg_ca}-root.crt"
71
72                 test "Корректный хэндшейк $suite" {
73                         remote_client $host
74                         set list [client_server [list -connect [info hostname]:4433 \
75                                 -CAfile $ca_file -state -cipher $cs] \
76                                 [concat [list -www -cert srv_$alg_fn/cert.pem \
77                                 -key srv_$alg_fn/seckey.pem -cipher $mycs] $protos($proto)] {}]
78                         set cln_exit_code [lindex $list 2]
79                         set srv_error [string match "*error*" [lindex $list 4]]
80                         if {[regexp -lineanchor \
81                         {^\s*Protocol\s*:\s*(\S*)\s*$.*^\s*Cipher\s*:\s*(\S*)\s*$} \
82                         [lindex $list 0] -> result_proto result_cipher]} {
83                                 if {$proto == "default"} {set result_proto "default"}
84                                 list $cln_exit_code $srv_error $result_proto $result_cipher
85                         } else {
86                                 lindex $list 1
87                         }       
88                 } 0 [list 0 0 $proto $cs]
89
90
91                 test "Сервер требует сертификат, сертификата нет $suite" {
92                         remote_client $host
93                         set list [client_server [list -connect [info hostname]:4433 \
94                                 -CAfile $ca_file -state -cipher $cs] \
95                                 [concat [list -www -cert srv_$alg_fn/cert.pem \
96                                 -key srv_$alg_fn/seckey.pem -cipher $mycs -Verify 3 \
97                                 -verify_return_error] $protos($proto)] {}]
98                         string match "*error*" [lindex $list 4]
99                 } 0 1 
100
101
102                 test "Некорректный клиентский сертфиикат $suite" {
103                         remote_client $host
104                         set list [client_server [list -connect [info hostname]:4433 \
105                                 -cert /home/build/client-$alg_ca/cert.pem \
106                                 -key /home/build/client-$alg_ca/seckey.pem \
107                                 -CAfile $ca_file -state -cipher $cs] \
108                                 [concat [list -www -cert srv_$alg_fn/cert.pem \
109                                 -key srv_$alg_fn/seckey.pem -cipher $mycs -Verify 3 \
110                                 -verify_return_error] $protos($proto)] {}]
111                         string match "*error*" [lindex $list 4]
112                 } 0 1
113
114
115
116                 foreach alg_cli $alg_cli_list {
117
118                         test "Клиентский сертификат $alg_cli $suite" {
119                                 remote_client $host
120                                 set list [client_server [list -connect [info hostname]:4433 \
121                                         -cert /home/build/client-$alg_cli/cert.pem \
122                                         -key /home/build/client-$alg_cli/seckey.pem \
123                                         -CAfile $ca_file -state -cipher $cs] \
124                                         [concat [list -www -cert srv_$alg_fn/cert.pem \
125                                         -key srv_$alg_fn/seckey.pem -CAfile ca_$alg_ca.pem \
126                                         -cipher $mycs -Verify 3 -verify_return_error] \
127                                         $protos($proto)] {}]
128                                 set cln_exit_code [lindex $list 2]
129                                 set srv_error [string match "*error*" [lindex $list 4]]
130                                 if {[regexp -lineanchor \
131                                 {^\s*Protocol\s*:\s*(\S*)\s*$.*^\s*Cipher\s*:\s*(\S*)\s*$} \
132                                 [lindex $list 0] -> result_proto result_cipher]} {
133                                         if {$proto == "default"} {set result_proto "default"}
134                                         list $cln_exit_code $srv_error $result_proto $result_cipher
135                                 } else {
136                                         lindex $list 1
137                                 }       
138                         } 0 [list 0 0 $proto $cs]
139                 }
140         }
141 }       
142 end_tests