@@ -47,13 +47,17 @@ mkdir($SOFTHSM2_TOKENDIR);
47
47
$ PHP11_PIN =123456 ;
48
48
$ PHP11_SOPIN =12345678 ;
49
49
50
- file_put_contents ($ SOFTHSM2_CONF , sprintf (
51
- "directories.tokendir = %s " .PHP_EOL .
52
- "objectstore.backend = file " .PHP_EOL .
53
- "log.level = DEBUG " .PHP_EOL .
54
- "slots.removable = false " .PHP_EOL .
50
+ file_put_contents (
51
+ $ SOFTHSM2_CONF ,
52
+ sprintf (
53
+ "directories.tokendir = %s " . PHP_EOL .
54
+ "objectstore.backend = file " . PHP_EOL .
55
+ "log.level = DEBUG " . PHP_EOL .
56
+ "slots.removable = false " . PHP_EOL .
55
57
"slots.mechanisms = ALL " ,
56
- $ SOFTHSM2_TOKENDIR ));
58
+ $ SOFTHSM2_TOKENDIR
59
+ )
60
+ );
57
61
58
62
putenv (sprintf ("SOFTHSM2_CONF=%s " , $ SOFTHSM2_CONF ));
59
63
sexec ("softhsm2-util --show-slots | grep ^Slot | cut -d ' ' -f 2 " , $ out );
@@ -72,7 +76,7 @@ sexec(sprintf("softhsm2-util --init-token --free --slot %d --label TestVJToken -
72
76
sexec (sprintf ("pkcs11-dump slotlist %s 2>/dev/null | grep SoftHSM | head -1 | cut -f 1 " ,
73
77
$ PKCS11_MODULE_PATH ), $ PHP11_SLOT );
74
78
if (!is_string ($ PHP11_SLOT )) {
75
- echo "Cannot detect the slot " . PHP_EOL ;
79
+ echo "Cannot detect the slot " . PHP_EOL ;
76
80
exit (1 );
77
81
}
78
82
$ PHP11_SLOT =(int )$ PHP11_SLOT ;
@@ -109,31 +113,31 @@ sexec(sprintf("pkcs11-tool --login --pin %s --write-object %s --type cert --l
109
113
110
114
$ key = openssl_pkey_get_private (sprintf ("pkcs11:object=VJPrivKey;type=private;pin-value=%s " , $ PHP11_PIN ));
111
115
if (!($ key instanceof OpenSSLAsymmetricKey)) {
112
- echo "Private Key NOK " . PHP_EOL ;
116
+ echo "Private Key NOK " . PHP_EOL ;
113
117
exit (1 );
114
118
}
115
- echo "Private Key OK " . PHP_EOL ;
119
+ echo "Private Key OK " . PHP_EOL ;
116
120
117
121
$ key = openssl_pkey_get_public (sprintf ("pkcs11:object=VJPubKey;type=public " ));
118
122
if (!($ key instanceof OpenSSLAsymmetricKey)) {
119
- echo "Public Key NOK " . PHP_EOL ;
123
+ echo "Public Key NOK " . PHP_EOL ;
120
124
exit (1 );
121
125
}
122
- echo "Public Key OK " . PHP_EOL ;
126
+ echo "Public Key OK " . PHP_EOL ;
123
127
124
128
$ cert = openssl_x509_read (sprintf ("pkcs11:object=VJCert;type=cert " ));
125
129
if (!($ cert instanceof OpenSSLCertificate)) {
126
- echo "Cert NOK " . PHP_EOL ;
130
+ echo "Cert NOK " . PHP_EOL ;
127
131
exit (1 );
128
132
}
129
- echo "Cert OK " . PHP_EOL ;
133
+ echo "Cert OK " . PHP_EOL ;
130
134
$ certArray =openssl_x509_parse ($ cert );
131
135
132
136
if ($ certArray ['name ' ] !== "/CN=MyCertVJ " ) {
133
- echo "Cert content NOK " . PHP_EOL ;
137
+ echo "Cert content NOK " . PHP_EOL ;
134
138
exit (1 );
135
139
}
136
- echo "Cert content OK " . PHP_EOL ;
140
+ echo "Cert content OK " . PHP_EOL ;
137
141
138
142
?>
139
143
--EXPECT--
0 commit comments