blob: 69f43b8b9d71249ba606974d0f7f2aebeb4329bb (
plain)
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
|
# file : tests/agent-pkcs11.testscript
# license : MIT; see accompanying LICENSE file
: args
:
{
: none
:
$* 2>'error: private key URL argument expected' != 0
: invalid-url
:
$* 'http://key' 2>'error: invalid PKCS#11 URL: invalid scheme' != 0
}
: existent-module
:
{
url = 'pkcs11:?pin-value=123123'
: failure
:
$* --simulate failure "$url" 2>>EOE != 0
error: no matching private key found
EOE
: success
:
{
$* --simulate success "$url" | set script;
sed -n -e 's/^OPENSSL_AGENT_PKCS11_PID=(.+);.+;$/\1/p' <"$script" | \
set pid;
echo "$script" >>~"%EOO%";
%OPENSSL_AGENT_PKCS11_SOCK=.+; export OPENSSL_AGENT_PKCS11_SOCK;%
OPENSSL_AGENT_PKCS11_PID=$pid; export OPENSSL_AGENT_PKCS11_PID;
echo Agent pid $pid
EOO
kill -0 "$pid"; # Make sure the agent is running.
kill "$pid"; # Signal the agent to terminate.
sleep 2; # Wait a bit while the agent is terminating.
# Make sure the agent is not running.
#
# Normally two seconds should be enough for the agent to terminate. It can
# probably take longer in some rear cases, but not being able to terminate
# in ten seconds most likely indicates an issue.
#
if kill -0 "$pid" 2>!
sleep 8
kill -0 "$pid" 2>! != 0
end
}
}
: non-existent-module
:
{
url = 'pkcs11:?pin-value=123123&module-name=non-existing-pkcs11-module'
: failure
:
$* --simulate failure "$url" 2>>EOE != 0
error: no matching private key found
EOE
: success
:
{
$* --simulate success "$url" | set script;
sed -n -e 's/^OPENSSL_AGENT_PKCS11_PID=(.+);.+;$/\1/p' <"$script" | \
set pid;
kill -0 "$pid"; # Make sure the agent is running.
kill "$pid" # Signal the agent to terminate.
}
}
|