Skip to content

Commit e29a428

Browse files
authored
Merge pull request #335 from dgarske/ocspnb_async
Example for OCSP non-blocking with async.
2 parents c327ef6 + 973ee67 commit e29a428

2 files changed

Lines changed: 573 additions & 0 deletions

File tree

ocsp/ocsp_nonblock/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,93 @@ OCSP Response: ret 471, nonblock count 409421
3232
Check OCSP for Google.com (ret 1)
3333
Ret = 1: success
3434
```
35+
36+
## OCSP non-blocking Async example
37+
38+
This uses your system certificate chain to demonstrate validating revocation status using an OCSP
39+
public server with wolfSSL's Asynchronous crypto.
40+
41+
The example uses youtube.com as the public server.
42+
43+
Example usage:
44+
45+
```sh
46+
$ ./configure --enable-ocsp --enable-asynccrypt --enable-sni --enable-alpn --enable-ocspstapling
47+
--enable-ocspstapling2 --enable-opensslextra --enable-curve25519 CFLAGS="-DWOLFSSL_NONBLOCK_OCSP"
48+
$ make
49+
$ sudo make install
50+
51+
% make
52+
gcc -o ocsp_nonblock_async ocsp_nonblock_async.c -Wall -I/usr/local/include -Os -L/usr/local/lib -lwolfssl
53+
54+
% ./ocsp_nonblock_async
55+
WolfSSL AsyncCrypt Enabled
56+
WolfSSL AsyncCrypt with Simulation Mode
57+
Connecting...
58+
wolfSSL_connect() returned -1 (error code -108)
59+
wolfSSL_connect() returned -1 (error code -108)
60+
wolfSSL_connect() returned -1 (error code -108)
61+
ocsp_cb(): http://ocsp.pki.goog/gsr1
62+
simulate 'want read'
63+
wolfSSL_connect() returned -1 (error code -408)
64+
ocsp_cb(): http://ocsp.pki.goog/gsr1
65+
Running command:
66+
curl -s --data-binary '@ocsp.req' -o 'ocsp.resp' -X POST -H 'Cache-Control: no-cache' -H 'Content-Type: application/ocsp-request' 'http://ocsp.pki.goog/gsr1'
67+
Reading OCSP response from file...
68+
Read 1447 bytes.
69+
*response is (nil)
70+
Allocating 1447 bytes...
71+
*response is now 0x55ef7fdcb4e0
72+
Copying bytes...
73+
Bytes copied.
74+
verify_cb()
75+
preverify_ok = 1
76+
wolfSSL_connect() returned -1 (error code -108)
77+
ocsp_cb(): http://ocsp.pki.goog/gtsr1
78+
simulate 'want read'
79+
wolfSSL_connect() returned -1 (error code -408)
80+
ocsp_cb(): http://ocsp.pki.goog/gtsr1
81+
Running command:
82+
curl -s --data-binary '@ocsp.req' -o 'ocsp.resp' -X POST -H 'Cache-Control: no-cache' -H 'Content-Type: application/ocsp-request' 'http://ocsp.pki.goog/gtsr1'
83+
Reading OCSP response from file...
84+
Read 724 bytes.
85+
*response is (nil)
86+
Allocating 724 bytes...
87+
*response is now 0x55ef7fdaf030
88+
Copying bytes...
89+
Bytes copied.
90+
verify_cb()
91+
preverify_ok = 1
92+
wolfSSL_connect() returned -1 (error code -108)
93+
ocsp_cb(): http://ocsp.pki.goog/gts1c3
94+
simulate 'want read'
95+
wolfSSL_connect() returned -1 (error code -408)
96+
ocsp_cb(): http://ocsp.pki.goog/gts1c3
97+
Running command:
98+
curl -s --data-binary '@ocsp.req' -o 'ocsp.resp' -X POST -H 'Cache-Control: no-cache' -H 'Content-Type: application/ocsp-request' 'http://ocsp.pki.goog/gts1c3'
99+
Reading OCSP response from file...
100+
Read 472 bytes.
101+
*response is (nil)
102+
Allocating 472 bytes...
103+
*response is now 0x55ef7fdac4b0
104+
Copying bytes...
105+
Bytes copied.
106+
verify_cb()
107+
preverify_ok = 1
108+
wolfSSL_connect() returned -1 (error code -108)
109+
CONNECTED
110+
Closing connection...
111+
wolfSSL_shutdown() failed with code 2 (error 0)
112+
CLOSED
113+
test_connect() failed
114+
CONNECT FAILED
115+
116+
DONE
117+
```
118+
119+
The example uses `/etc/ssl/certs/ca-certificates.crt` as the system certs file by default. If your
120+
system doesn't have this file, just run the executable with the path to your own cert file.
121+
122+
```
123+
./ocsp_nonblock_asynccrypt ../../mycerts/ca.crt
124+
```

0 commit comments

Comments
 (0)