Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • d5794a1
  • /
  • openssl-server-pha.expect
Raw File
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:0c51eb41ae418e17cf9e8aa49e12d7e5066ba60d
directory badge Iframe embedding
swh:1:dir:d5794a1fedb3ce12817214fae794962808624229
openssl-server-pha.expect
#!/usr/bin/expect
# execute like this:
# openssl-server-pha.expect openssl s_server -key /tmp/server/key.pem -cert /tmp/server/cert.pem -CAfile /tmp/ca/cert.pem
set timeout 30
set exp_internal 1
eval spawn $argv
trap { exec kill -SIGTERM [exp_pid] } SIGTERM
expect {
    "CIPHER is" {
        expect {
            "GET / HTTP/1.0" { send "HTTP/1.0 200 ok\r"; }
            "GET /secret HTTP/1.0" {
                send "c\r";
                send_user "== expect: waiting for client cert\n";
                set timeout 1;
                expect {
                    "verify return:1" {
                        expect {
                            "Read BLOCK" { send "HTTP/1.0 200 ok\r"; }
                            "error" { }
                            "ERROR" { }
                            eof { exit 15 }
                            timeout { exit 16 }
                        }
                    } timeout {
                        send_user "== expect: no certificate received\n";
                        send "HTTP/1.0 401 authentication required\r";
                    }
                    "ERROR" { }
                    eof { exit 13 }
                }
                send_user "== expect: client cert handled\n";
                set timeout 10;
            }
            eof { exit 11 }
            timeout { exit 12 }
        }
        exp_continue;
    }
    eof { exit 7 }
    timeout { close; exit 8 }
}
set info [wait]
exit [lindex $info 3]

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top