Commit 70e4b2f
authored
Add -msg and -servername support to openssl s_client (#3098)
### Description of changes:
Add -msg flag with full implementation using SSL_set_msg_callback to
print TLS protocol messages in OpenSSL-compatible format.
Add -servername flag that maps to DoClient's existing -server-name
for SNI support.
### Call-outs:
I did not end up printing the hex dumps of each message like OpenSSL
does. Should be easy enough to add if we wanted to, but the
compatibility gap being addressed by this does not require it.
The `-msg` argument only applies to `s_client` but it had to be
implemented inside `client.cc` because it impacts the `SSL_CTX`. This
may raise the eyebrows of some purists.
### Testing:
How is this change tested (unit tests, fuzz tests, etc.)? Are there any
testing steps to be verified by the reviewer?
```
# Example -msg output
➜ tool-openssl git:(msg-fix) ✗ ./openssl s_client -connect amazon.com:443 -msg -servername amazon.com | grep -E '>>>|<<<'
>>> TLS 1.2, RecordHeader [length 0005]
>>> TLS 1.2, Handshake [length 05c8], ClientHello
<<< TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.2, Handshake [length 007a], ServerHello
>>> TLS 1.2, RecordHeader [length 0005]
>>> TLS 1.3, ChangeCipherSpec [length 0001]
<<< TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.3, Handshake [length 000a], EncryptedExtensions
<<< TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.3, Handshake [length 144c], Certificate
<<< TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.3, Handshake [length 0108], CertificateVerify
<<< TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.3, Handshake [length 0024], Finished
>>> TLS 1.3, Handshake [length 0024], Finished
>>> TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.3, Handshake [length 0039], NewSessionTicket
<<< TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.3, Handshake [length 0039], NewSessionTicket
<<< TLS 1.2, RecordHeader [length 0005]
<<< TLS 1.3, Alert [length 0002]
```
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.1 parent ad3a9c0 commit 70e4b2f
2 files changed
Lines changed: 102 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
70 | 80 | | |
71 | 81 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
313 | 401 | | |
314 | 402 | | |
315 | 403 | | |
| |||
349 | 437 | | |
350 | 438 | | |
351 | 439 | | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
352 | 444 | | |
353 | 445 | | |
354 | 446 | | |
| |||
0 commit comments