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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
|
.\"
.\" $OpenBSD: ssl.3,v 1.1 2016/11/05 15:32:20 schwarze Exp $
.\"
.Dd $Mdocdate: November 5 2016 $
.Dt SSL 3
.Os
.Sh NAME
.Nm ssl
.Nd OpenSSL SSL/TLS library
.Sh DESCRIPTION
The OpenSSL
.Nm ssl
library implements the Secure Sockets Layer (SSL v2/v3) and
Transport Layer Security (TLS v1) protocols.
It provides a rich API which is documented here.
.Pp
At first the library must be initialized; see
.Xr SSL_library_init 3 .
.Pp
Then an
.Vt SSL_CTX
object is created as a framework to establish TLS/SSL enabled connections (see
.Xr SSL_CTX_new 3 ) .
Various options regarding certificates, algorithms, etc., can be set in this
object.
.Pp
When a network connection has been created, it can be assigned to an
.Vt SSL
object.
After the
.Vt SSL
object has been created using
.Xr SSL_new 3 ,
.Xr SSL_set_fd 3
or
.Xr SSL_set_bio 3
can be used to associate the network connection with the object.
.Pp
Then the TLS/SSL handshake is performed using
.Xr SSL_accept 3
or
.Xr SSL_connect 3
respectively.
.Xr SSL_read 3
and
.Xr SSL_write 3
are used to read and write data on the TLS/SSL connection.
.Xr SSL_shutdown 3
can be used to shut down the TLS/SSL connection.
.Sh DATA STRUCTURES
Currently the OpenSSL
.Nm ssl
library functions deals with the following data structures:
.Bl -tag -width Ds
.It Vt SSL_METHOD No (SSL Method)
That's a dispatch structure describing the internal
.Nm ssl
library methods/functions which implement the various protocol versions
(SSLv1, SSLv2 and TLSv1).
It's needed to create an
.Vt SSL_CTX .
.It Vt SSL_CIPHER No (SSL Cipher)
This structure holds the algorithm information for a particular cipher which
is a core part of the SSL/TLS protocol.
The available ciphers are configured on an
.Vt SSL_CTX
basis and the actually used ones are then part of the
.Vt SSL_SESSION .
.It Vt SSL_CTX No (SSL Context)
That's the global context structure which is created by a server or client
once per program lifetime and which holds mainly default values for the
.Vt SSL
structures which are later created for the connections.
.It Vt SSL_SESSION No (SSL Session)
This is a structure containing the current TLS/SSL session details for a
connection:
.Vt SSL_CIPHER Ns s, client and server certificates, keys, etc.
.It Vt SSL No (SSL Connection)
That's the main SSL/TLS structure which is created by a server or client per
established connection.
This actually is the core structure in the SSL API.
Under run-time the application usually deals with this structure which has
links to mostly all other structures.
.El
.Sh HEADER FILES
Currently the OpenSSL
.Nm ssl
library provides the following C header files containing the prototypes for the
data structures and functions:
.Bl -tag -width Ds
.It Pa ssl.h
That's the common header file for the SSL/TLS API.
Include it into your program to make the API of the
.Nm ssl
library available.
It internally includes both more private SSL headers and headers from the
.Em crypto
library.
Whenever you need hardcore details on the internals of the SSL API, look inside
this header file.
.It Pa ssl2.h
That's the sub header file dealing with the SSLv2 protocol only.
.Bf Em
Usually you don't have to include it explicitly because it's already included
by
.Pa ssl.h .
.Ef
.It Pa ssl3.h
That's the sub header file dealing with the SSLv3 protocol only.
.Bf Em
Usually you don't have to include it explicitly because it's already included
by
.Pa ssl.h .
.Ef
.It Pa ssl23.h
That's the sub header file dealing with the combined use of the SSLv2 and SSLv3
protocols.
.Bf Em
Usually you don't have to include it explicitly because it's already included
by
.Pa ssl.h .
.Ef
.It Pa tls1.h
That's the sub header file dealing with the TLSv1 protocol only.
.Bf Em
Usually you don't have to include it explicitly because it's already included
by
.Pa ssl.h .
.Ef
.El
.Sh API FUNCTIONS
The functions that the OpenSSL
.Nm ssl
library exports are documented below:
.Ss DEALING WITH PROTOCOL METHODS
Here we document the various API functions which deal with the SSL/TLS protocol
methods defined in
.Vt SSL_METHOD
structures.
.Bl -tag -width Ds
.It Xo
.Ft const SSL_METHOD *
.Fn SSLv2_client_method void
.Xc
Constructor for the SSLv2
.Vt SSL_METHOD
structure for a dedicated client.
.It Xo
.Ft const SSL_METHOD *
.Fn SSLv2_server_method void
.Xc
Constructor for the SSLv2
.Vt SSL_METHOD
structure for a dedicated server.
.It Xo
.Ft const SSL_METHOD *
.Fn SSLv2_method void
.Xc
Constructor for the SSLv2
.Vt SSL_METHOD
structure for combined client and server.
.It Xo
.Ft const SSL_METHOD *
.Fn SSLv3_client_method void
.Xc
Constructor for the SSLv3
.Vt SSL_METHOD
structure for a dedicated client.
.It Xo
.Ft const SSL_METHOD *
.Fn SSLv3_server_method void
.Xc
Constructor for the SSLv3
.Vt SSL_METHOD
structure for a dedicated server.
.It Xo
.Ft const SSL_METHOD *
.Fn SSLv3_method void
.Xc
Constructor for the SSLv3
.Vt SSL_METHOD
structure for combined client and server.
.It Xo
.Ft const SSL_METHOD *
.Fn TLSv1_client_method void
.Xc
Constructor for the TLSv1
.Vt SSL_METHOD
structure for a dedicated client.
.It Xo
.Ft const SSL_METHOD *
.Fn TLSv1_server_method void
.Xc
Constructor for the TLSv1
.Vt SSL_METHOD
structure for a dedicated server.
.It Xo
.Ft const SSL_METHOD *
.Fn TLSv1_method void
.Xc
Constructor for the TLSv1
.Vt SSL_METHOD
structure for combined client and server.
.El
.Ss DEALING WITH CIPHERS
Here we document the various API functions which deal with the SSL/TLS ciphers
defined in
.Vt SSL_CIPHER
structures.
.Bl -tag -width Ds
.It Xo
.Ft char *
.Fn SSL_CIPHER_description "SSL_CIPHER *cipher" "char *buf" "int len"
.Xc
Write a string to
.Fa buf
(with a maximum size of
.Fa len )
containing a human readable description of
.Fa cipher .
Returns
.Fa buf .
.It Xo
.Ft int
.Fn SSL_CIPHER_get_bits "SSL_CIPHER *cipher" "int *alg_bits"
.Xc
Determine the number of bits in
.Fa cipher .
Because of export crippled ciphers there are two bits:
the bits the algorithm supports in general (stored to
.Fa alg_bits )
and the bits which are actually used (the return value).
.It Xo
.Ft const char *
.Fn SSL_CIPHER_get_name "SSL_CIPHER *cipher"
.Xc
Return the internal name of
.Fa cipher
as a string.
These are the various strings defined by the
.Dv SSL2_TXT_xxx ,
.Dv SSL3_TXT_xxx
and
.Dv TLS1_TXT_xxx
definitions in the header files.
.It Xo
.Ft char *
.Fn SSL_CIPHER_get_version "SSL_CIPHER *cipher"
.Xc
Returns a string like
Qq TLSv1/SSLv3
or
Qq SSLv2
which indicates the SSL/TLS protocol version to which
.Fa cipher
belongs (i.e., where it was defined in the specification the first time).
.El
.Ss DEALING WITH PROTOCOL CONTEXTS
Here we document the various API functions which deal with the SSL/TLS
protocol context defined in the
.Vt SSL_CTX
structure.
.Bl -tag -width Ds
.It Xo
.Ft int
.Fn SSL_CTX_add_client_CA "SSL_CTX *ctx" "X509 *x"
.Xc
.It Xo
.Ft long
.Fn SSL_CTX_add_extra_chain_cert "SSL_CTX *ctx" "X509 *x509"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_add_session "SSL_CTX *ctx" "SSL_SESSION *c"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_check_private_key "const SSL_CTX *ctx"
.Xc
.It Xo
.Ft long
.Fn SSL_CTX_ctrl "SSL_CTX *ctx" "int cmd" "long larg" "char *parg"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_flush_sessions "SSL_CTX *s" "long t"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_free "SSL_CTX *a"
.Xc
.It Xo
.Ft char *
.Fn SSL_CTX_get_app_data "SSL_CTX *ctx"
.Xc
.It Xo
.Ft X509_STORE *
.Fn SSL_CTX_get_cert_store "SSL_CTX *ctx"
.Xc
.It Xo
.Ft STACK *
.Fn SSL_CTX_get_client_CA_list "const SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn "(*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))"
.Fa "SSL *ssl" "X509 **x509" "EVP_PKEY **pkey"
.Xc
.It Xo
.Ft char *
.Fn SSL_CTX_get_ex_data "const SSL_CTX *s" "int idx"
.Xc
.It Xo
.Ft int
.Fo SSL_CTX_get_ex_new_index
.Fa "long argl"
.Fa "void *argp"
.Fa "CRYPTO_EX_new *new_func"
.Fa "CRYPTO_EX_dup *dup_func"
.Fa "CRYPTO_EX_free *free_func"
.Fc
.Xc
.It Xo
.Ft void
.Fo "(*SSL_CTX_get_info_callback(const SSL_CTX *ctx))"
.Fa "SSL *ssl"
.Fa "int cb"
.Fa "int ret"
.Fc
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_get_quiet_shutdown "const SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_get_session_cache_mode "SSL_CTX *ctx"
.Xc
.It Xo
.Ft long
.Fn SSL_CTX_get_timeout "const SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fo "(*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))"
.Fa "int ok"
.Fa "X509_STORE_CTX *ctx"
.Fc
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_get_verify_mode "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_load_verify_locations "SSL_CTX *ctx" "char *CAfile" "char *CApath"
.Xc
.It Xo
.Ft long
.Fn SSL_CTX_need_tmp_RSA "SSL_CTX *ctx"
.Xc
.It Xo
.Ft SSL_CTX *
.Fn SSL_CTX_new "const SSL_METHOD *meth"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_remove_session "SSL_CTX *ctx" "SSL_SESSION *c"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_accept "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_accept_good "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_accept_renegotiate "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_cache_full "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_cb_hits "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_connect "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_connect_good "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_connect_renegotiate "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_get_cache_size "SSL_CTX *ctx"
.Xc
.It Xo
.Ft SSL_SESSION *
.Fo "(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))"
.Fa "SSL *ssl"
.Fa "unsigned char *data"
.Fa "int len"
.Fa "int *copy"
.Fc
.Xc
.It Xo
.Ft int
.Fn "(*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))" "SSL *ssl" "SSL_SESSION *sess"
.Xc
.It Xo
.Ft void
.Fo "(*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))"
.Fa "SSL_CTX *ctx"
.Fa "SSL_SESSION *sess"
.Fc
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_hits "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_misses "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_number "SSL_CTX *ctx"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_sess_set_cache_size "SSL_CTX *ctx" "long t"
.Xc
.It Xo
.Ft void
.Fo SSL_CTX_sess_set_get_cb
.Fa "SSL_CTX *ctx"
.Fa "SSL_SESSION *(*cb)(SSL *ssl, unsigned char *data, int len, int *copy)"
.Fc
.Xc
.It Xo
.Ft void
.Fo SSL_CTX_sess_set_new_cb
.Fa "SSL_CTX *ctx"
.Fa "int (*cb)(SSL *ssl, SSL_SESSION *sess)"
.Fc
.Xc
.It Xo
.Ft void
.Fo SSL_CTX_sess_set_remove_cb
.Fa "SSL_CTX *ctx"
.Fa "void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess)"
.Fc
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_sess_timeouts "SSL_CTX *ctx"
.Xc
.It Xo
.Ft LHASH *
.Fn SSL_CTX_sessions "SSL_CTX *ctx"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_app_data "SSL_CTX *ctx" "void *arg"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_cert_store "SSL_CTX *ctx" "X509_STORE *cs"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_cert_verify_cb "SSL_CTX *ctx" "int (*cb)()" "char *arg"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_set_cipher_list "SSL_CTX *ctx" "char *str"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_client_CA_list "SSL_CTX *ctx" "STACK *list"
.Xc
.It Xo
.Ft void
.Fo SSL_CTX_set_client_cert_cb
.Fa "SSL_CTX *ctx"
.Fa "int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)"
.Fc
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_default_passwd_cb "SSL_CTX *ctx" "pem_password_cb *cb"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_default_read_ahead "SSL_CTX *ctx" "int m"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_set_default_verify_paths "SSL_CTX *ctx"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_set_ex_data "SSL_CTX *s" "int idx" "char *arg"
.Xc
.It Xo
.Ft void
.Fo SSL_CTX_set_info_callback
.Fa "SSL_CTX *ctx"
.Fa "void (*cb)(SSL *ssl, int cb, int ret)"
.Fc
.Xc
.It Xo
.Ft void
.Fo SSL_CTX_set_msg_callback
.Fa "SSL_CTX *ctx"
.Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, \
size_t len, SSL *ssl, void *arg)"
.Fc
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_msg_callback_arg "SSL_CTX *ctx" "void *arg"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_options "SSL_CTX *ctx" "unsigned long op"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_quiet_shutdown "SSL_CTX *ctx" "int mode"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_session_cache_mode "SSL_CTX *ctx" "int mode"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_set_ssl_version "SSL_CTX *ctx" "const SSL_METHOD *meth"
.Xc
.It Xo
.Ft void
.Fn SSL_CTX_set_timeout "SSL_CTX *ctx" "long t"
.Xc
.It Xo
.Ft long
.Fn SSL_CTX_set_tmp_dh "SSL_CTX* ctx" "DH *dh"
.Xc
.It Xo
.Ft long
.Fn SSL_CTX_set_tmp_dh_callback "SSL_CTX *ctx" "DH *(*cb)(void)"
.Xc
.It Xo
.Ft long
.Fn SSL_CTX_set_tmp_rsa "SSL_CTX *ctx" "RSA *rsa"
.Xc
.It Xo
.Fn SSL_CTX_set_tmp_rsa_callback
.Xc
.Ft long
.Fo SSL_CTX_set_tmp_rsa_callback
.Fa "SSL_CTX *ctx"
.Fa "RSA *(*cb)(SSL *ssl, int export, int keylength)"
.Fc
.Pp
Sets the callback which will be called when a temporary private key is
required.
The
.Fa export
flag will be set if the reason for needing a temp key is that an export
ciphersuite is in use, in which case,
.Fa keylength
will contain the required keylength in bits.
.\" XXX using what?
Generate a key of appropriate size (using ???) and return it.
.It Xo
.Fn SSL_set_tmp_rsa_callback
.Xc
.Ft long
.Fo SSL_set_tmp_rsa_callback
.Fa "SSL *ssl"
.Fa "RSA *(*cb)(SSL *ssl, int export, int keylength)"
.Fc
.Pp
The same as
.Fn SSL_CTX_set_tmp_rsa_callback ,
except it operates on an
.Vt SSL
session instead of a context.
.It Xo
.Ft void
.Fn SSL_CTX_set_verify "SSL_CTX *ctx" "int mode" "int (*cb)(void)"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_use_PrivateKey "SSL_CTX *ctx" "EVP_PKEY *pkey"
.Xc
.It Xo
.Ft int
.Fo SSL_CTX_use_PrivateKey_ASN1
.Fa "int type"
.Fa "SSL_CTX *ctx"
.Fa "unsigned char *d"
.Fa "long len"
.Fc
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_use_PrivateKey_file "SSL_CTX *ctx" "char *file" "int type"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_use_RSAPrivateKey "SSL_CTX *ctx" "RSA *rsa"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_use_RSAPrivateKey_ASN1 "SSL_CTX *ctx" "unsigned char *d" "long len"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_use_RSAPrivateKey_file "SSL_CTX *ctx" "char *file" "int type"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_use_certificate "SSL_CTX *ctx" "X509 *x"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_use_certificate_ASN1 "SSL_CTX *ctx" "int len" "unsigned char *d"
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_use_certificate_file "SSL_CTX *ctx" "char *file" "int type"
.Xc
.It Xo
.Ft void
.Fo SSL_CTX_set_psk_client_callback
.Fa "SSL_CTX *ctx"
.Fa "unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, \
unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)"
.Fc
.Xc
.It Xo
.Ft int
.Fn SSL_CTX_use_psk_identity_hint "SSL_CTX *ctx" "const char *hint"
.Xc
.It Xo
.Ft void
.Fo SSL_CTX_set_psk_server_callback
.Fa "SSL_CTX *ctx"
.Fa "unsigned int (*callback)(SSL *ssl, const char *identity, \
unsigned char *psk, int max_psk_len)"
.Fc
.Xc
.El
.Ss DEALING WITH SESSIONS
Here we document the various API functions which deal with the SSL/TLS sessions
defined in the
.Vt SSL_SESSION
structures.
.Bl -tag -width Ds
.It Xo
.Ft int
.Fn SSL_SESSION_cmp "const SSL_SESSION *a" "const SSL_SESSION *b"
.Xc
.It Xo
.Ft void
.Fn SSL_SESSION_free "SSL_SESSION *ss"
.Xc
.It Xo
.Ft char *
.Fn SSL_SESSION_get_app_data "SSL_SESSION *s"
.Xc
.It Xo
.Ft char *
.Fn SSL_SESSION_get_ex_data "const SSL_SESSION *s" "int idx"
.Xc
.It Xo
.Ft int
.Fo SSL_SESSION_get_ex_new_index
.Fa "long argl"
.Fa "char *argp"
.Fa "int (*new_func)(void)"
.Fa "int (*dup_func)(void), void (*free_func)(void)"
.Fc
.Xc
.It Xo
.Ft long
.Fn SSL_SESSION_get_time "const SSL_SESSION *s"
.Xc
.It Xo
.Ft long
.Fn SSL_SESSION_get_timeout "const SSL_SESSION *s"
.Xc
.It Xo
.Ft unsigned long
.Fn SSL_SESSION_hash "const SSL_SESSION *a"
.Xc
.It Xo
.Ft SSL_SESSION *
.Fn SSL_SESSION_new void
.Xc
.It Xo
.Ft int
.Fn SSL_SESSION_print "BIO *bp" "const SSL_SESSION *x"
.Xc
.It Xo
.Ft int
.Fn SSL_SESSION_print_fp "FILE *fp" "const SSL_SESSION *x"
.Xc
.It Xo
.Ft void
.Fn SSL_SESSION_set_app_data "SSL_SESSION *s" "char *a"
.Xc
.It Xo
.Ft int
.Fn SSL_SESSION_set_ex_data "SSL_SESSION *s" "int idx" "char *arg"
.Xc
.It Xo
.Ft long
.Fn SSL_SESSION_set_time "SSL_SESSION *s" "long t"
.Xc
.It Xo
.Ft long
.Fn SSL_SESSION_set_timeout "SSL_SESSION *s" "long t"
.Xc
.El
.Ss DEALING WITH CONNECTIONS
Here we document the various API functions which deal with the SSL/TLS
connection defined in the
.Vt SSL
structure.
.Bl -tag -width Ds
.It Xo
.Ft int
.Fn SSL_accept "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_add_dir_cert_subjects_to_stack "STACK *stack" "const char *dir"
.Xc
.It Xo
.Ft int
.Fn SSL_add_file_cert_subjects_to_stack "STACK *stack" "const char *file"
.Xc
.It Xo
.Ft int
.Fn SSL_add_client_CA "SSL *ssl" "X509 *x"
.Xc
.It Xo
.Ft char *
.Fn SSL_alert_desc_string "int value"
.Xc
.It Xo
.Ft char *
.Fn SSL_alert_desc_string_long "int value"
.Xc
.It Xo
.Ft char *
.Fn SSL_alert_type_string "int value"
.Xc
.It Xo
.Ft char *
.Fn SSL_alert_type_string_long "int value"
.Xc
.It Xo
.Ft int
.Fn SSL_check_private_key "const SSL *ssl"
.Xc
.It Xo
.Ft void
.Fn SSL_clear "SSL *ssl"
.Xc
.It Xo
.Ft long
.Fn SSL_clear_num_renegotiations "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_connect "SSL *ssl"
.Xc
.It Xo
.Ft void
.Fn SSL_copy_session_id "SSL *t" "const SSL *f"
.Xc
.It Xo
.Ft long
.Fn SSL_ctrl "SSL *ssl" "int cmd" "long larg" "char *parg"
.Xc
.It Xo
.Ft int
.Fn SSL_do_handshake "SSL *ssl"
.Xc
.It Xo
.Ft SSL *
.Fn SSL_dup "SSL *ssl"
.Xc
.It Xo
.Ft STACK *
.Fn SSL_dup_CA_list "STACK *sk"
.Xc
.It Xo
.Ft void
.Fn SSL_free "SSL *ssl"
.Xc
.It Xo
.Ft SSL_CTX *
.Fn SSL_get_SSL_CTX "const SSL *ssl"
.Xc
.It Xo
.Ft char *
.Fn SSL_get_app_data "SSL *ssl"
.Xc
.It Xo
.Ft X509 *
.Fn SSL_get_certificate "const SSL *ssl"
.Xc
.It Xo
.Ft const char *
.Fn SSL_get_cipher "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_get_cipher_bits "const SSL *ssl" "int *alg_bits"
.Xc
.It Xo
.Ft char *
.Fn SSL_get_cipher_list "const SSL *ssl" "int n"
.Xc
.It Xo
.Ft char *
.Fn SSL_get_cipher_name "const SSL *ssl"
.Xc
.It Xo
.Ft char *
.Fn SSL_get_cipher_version "const SSL *ssl"
.Xc
.It Xo
.Ft STACK *
.Fn SSL_get_ciphers "const SSL *ssl"
.Xc
.It Xo
.Ft STACK *
.Fn SSL_get_client_CA_list "const SSL *ssl"
.Xc
.It Xo
.Ft SSL_CIPHER *
.Fn SSL_get_current_cipher "SSL *ssl"
.Xc
.It Xo
.Ft long
.Fn SSL_get_default_timeout "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_get_error "const SSL *ssl" "int i"
.Xc
.It Xo
.Ft char *
.Fn SSL_get_ex_data "const SSL *ssl" "int idx"
.Xc
.It Xo
.Ft int
.Fn SSL_get_ex_data_X509_STORE_CTX_idx void
.Xc
.It Xo
.Ft int
.Fo SSL_get_ex_new_index
.Fa "long argl"
.Fa "char *argp"
.Fa "int (*new_func)(void)"
.Fa "int (*dup_func)(void)"
.Fa "void (*free_func)(void)"
.Fc
.Xc
.It Xo
.Ft int
.Fn SSL_get_fd "const SSL *ssl"
.Xc
.It Xo
.Ft void
.Fn "(*SSL_get_info_callback(const SSL *ssl))"
.Xc
.It Xo
.Ft STACK *
.Fn SSL_get_peer_cert_chain "const SSL *ssl"
.Xc
.It Xo
.Ft X509 *
.Fn SSL_get_peer_certificate "const SSL *ssl"
.Xc
.It Xo
.Ft EVP_PKEY *
.Fn SSL_get_privatekey "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_get_quiet_shutdown "const SSL *ssl"
.Xc
.It Xo
.Ft BIO *
.Fn SSL_get_rbio "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_get_read_ahead "const SSL *ssl"
.Xc
.It Xo
.Ft SSL_SESSION *
.Fn SSL_get_session "const SSL *ssl"
.Xc
.It Xo
.Ft char *
.Fn SSL_get_shared_ciphers "const SSL *ssl" "char *buf" "int len"
.Xc
.It Xo
.Ft int
.Fn SSL_get_shutdown "const SSL *ssl"
.Xc
.It Xo
.Ft const SSL_METHOD *
.Fn SSL_get_ssl_method "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_get_state "const SSL *ssl"
.Xc
.It Xo
.Ft long
.Fn SSL_get_time "const SSL *ssl"
.Xc
.It Xo
.Ft long
.Fn SSL_get_timeout "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn "(*SSL_get_verify_callback(const SSL *ssl))" int "X509_STORE_CTX *"
.Xc
.It Xo
.Ft int
.Fn SSL_get_verify_mode "const SSL *ssl"
.Xc
.It Xo
.Ft long
.Fn SSL_get_verify_result "const SSL *ssl"
.Xc
.It Xo
.Ft char *
.Fn SSL_get_version "const SSL *ssl"
.Xc
.It Xo
.Ft BIO *
.Fn SSL_get_wbio "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_in_accept_init "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_in_before "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_in_connect_init "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_in_init "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_is_init_finished "SSL *ssl"
.Xc
.It Xo
.Ft STACK *
.Fn SSL_load_client_CA_file "char *file"
.Xc
.It Xo
.Ft void
.Fn SSL_load_error_strings "void"
.Xc
.It Xo
.Ft SSL *
.Fn SSL_new "SSL_CTX *ctx"
.Xc
.It Xo
.Ft long
.Fn SSL_num_renegotiations "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_peek "SSL *ssl" "void *buf" "int num"
.Xc
.It Xo
.Ft int
.Fn SSL_pending "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_read "SSL *ssl" "void *buf" "int num"
.Xc
.It Xo
.Ft int
.Fn SSL_renegotiate "SSL *ssl"
.Xc
.It Xo
.Ft char *
.Fn SSL_rstate_string "SSL *ssl"
.Xc
.It Xo
.Ft char *
.Fn SSL_rstate_string_long "SSL *ssl"
.Xc
.It Xo
.Ft long
.Fn SSL_session_reused "SSL *ssl"
.Xc
.It Xo
.Ft void
.Fn SSL_set_accept_state "SSL *ssl"
.Xc
.It Xo
.Ft void
.Fn SSL_set_app_data "SSL *ssl" "char *arg"
.Xc
.It Xo
.Ft void
.Fn SSL_set_bio "SSL *ssl" "BIO *rbio" "BIO *wbio"
.Xc
.It Xo
.Ft int
.Fn SSL_set_cipher_list "SSL *ssl" "char *str"
.Xc
.It Xo
.Ft void
.Fn SSL_set_client_CA_list "SSL *ssl" "STACK *list"
.Xc
.It Xo
.Ft void
.Fn SSL_set_connect_state "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_set_ex_data "SSL *ssl" "int idx" "char *arg"
.Xc
.It Xo
.Ft int
.Fn SSL_set_fd "SSL *ssl" "int fd"
.Xc
.It Xo
.Ft void
.Fn SSL_set_info_callback "SSL *ssl" "void (*cb)(void)"
.Xc
.It Xo
.Ft void
.Fo SSL_set_msg_callback
.Fa "SSL *ctx"
.Fa "void (*cb)(int write_p, int version, int content_type, const void *buf, \
size_t len, SSL *ssl, void *arg)"
.Fc
.Xc
.It Xo
.Ft void
.Fn SSL_set_msg_callback_arg "SSL *ctx" "void *arg"
.Xc
.It Xo
.Ft void
.Fn SSL_set_options "SSL *ssl" "unsigned long op"
.Xc
.It Xo
.Ft void
.Fn SSL_set_quiet_shutdown "SSL *ssl" "int mode"
.Xc
.It Xo
.Ft void
.Fn SSL_set_read_ahead "SSL *ssl" "int yes"
.Xc
.It Xo
.Ft int
.Fn SSL_set_rfd "SSL *ssl" "int fd"
.Xc
.It Xo
.Ft int
.Fn SSL_set_session "SSL *ssl" "SSL_SESSION *session"
.Xc
.It Xo
.Ft void
.Fn SSL_set_shutdown "SSL *ssl" "int mode"
.Xc
.It Xo
.Ft int
.Fn SSL_set_ssl_method "SSL *ssl" "const SSL_METHOD *meth"
.Xc
.It Xo
.Ft void
.Fn SSL_set_time "SSL *ssl" "long t"
.Xc
.It Xo
.Ft void
.Fn SSL_set_timeout "SSL *ssl" "long t"
.Xc
.It Xo
.Ft void
.Fn SSL_set_verify "SSL *ssl" "int mode" "int (*callback)(void)"
.Xc
.It Xo
.Ft void
.Fn SSL_set_verify_result "SSL *ssl" "long arg"
.Xc
.It Xo
.Ft int
.Fn SSL_set_wfd "SSL *ssl" "int fd"
.Xc
.It Xo
.Ft int
.Fn SSL_shutdown "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_state "const SSL *ssl"
.Xc
.It Xo
.Ft char *
.Fn SSL_state_string "const SSL *ssl"
.Xc
.It Xo
.Ft char *
.Fn SSL_state_string_long "const SSL *ssl"
.Xc
.It Xo
.Ft long
.Fn SSL_total_renegotiations "SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_use_PrivateKey "SSL *ssl" "EVP_PKEY *pkey"
.Xc
.It Xo
.Ft int
.Fn SSL_use_PrivateKey_ASN1 "int type" "SSL *ssl" "unsigned char *d" "long len"
.Xc
.It Xo
.Ft int
.Fn SSL_use_PrivateKey_file "SSL *ssl" "char *file" "int type"
.Xc
.It Xo
.Ft int
.Fn SSL_use_RSAPrivateKey "SSL *ssl" "RSA *rsa"
.Xc
.It Xo
.Ft int
.Fn SSL_use_RSAPrivateKey_ASN1 "SSL *ssl" "unsigned char *d" "long len"
.Xc
.It Xo
.Ft int
.Fn SSL_use_RSAPrivateKey_file "SSL *ssl" "char *file" "int type"
.Xc
.It Xo
.Ft int
.Fn SSL_use_certificate "SSL *ssl" "X509 *x"
.Xc
.It Xo
.Ft int
.Fn SSL_use_certificate_ASN1 "SSL *ssl" "int len" "unsigned char *d"
.Xc
.It Xo
.Ft int
.Fn SSL_use_certificate_file "SSL *ssl" "char *file" "int type"
.Xc
.It Xo
.Ft int
.Fn SSL_version "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_want "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_want_nothing "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_want_read "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_want_write "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_want_x509_lookup "const SSL *ssl"
.Xc
.It Xo
.Ft int
.Fn SSL_write "SSL *ssl" "const void *buf" "int num"
.Xc
.It Xo
.Ft void
.Fo SSL_set_psk_client_callback
.Fa "SSL *ssl"
.Fa "unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, \
unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)"
.Fc
.Xc
.It Xo
.Ft int
.Fn SSL_use_psk_identity_hint "SSL *ssl" "const char *hint"
.Xc
.It Xo
.Ft void
.Fo SSL_set_psk_server_callback
.Fa "SSL *ssl"
.Fa "unsigned int (*callback)(SSL *ssl, const char *identity, \
unsigned char *psk, int max_psk_len)"
.Fc
.Xc
.It Xo
.Ft const char *
.Fn SSL_get_psk_identity_hint "SSL *ssl"
.Xc
.It Xo
.Ft const char *
.Fn SSL_get_psk_identity "SSL *ssl"
.Xc
.El
.Sh SEE ALSO
.Xr openssl 1 ,
.Xr crypto 3 ,
.Xr d2i_SSL_SESSION 3 ,
.Xr SSL_accept 3 ,
.Xr SSL_alert_type_string 3 ,
.Xr SSL_CIPHER_get_name 3 ,
.Xr SSL_clear 3 ,
.Xr SSL_COMP_add_compression_method 3 ,
.Xr SSL_connect 3 ,
.Xr SSL_CTX_add_extra_chain_cert 3 ,
.Xr SSL_CTX_add_session 3 ,
.Xr SSL_CTX_ctrl 3 ,
.Xr SSL_CTX_flush_sessions 3 ,
.Xr SSL_CTX_get_ex_new_index 3 ,
.Xr SSL_CTX_get_verify_mode 3 ,
.Xr SSL_CTX_load_verify_locations 3 ,
.Xr SSL_CTX_new 3 ,
.Xr SSL_CTX_sess_number 3 ,
.Xr SSL_CTX_sess_set_cache_size 3 ,
.Xr SSL_CTX_sess_set_get_cb 3 ,
.Xr SSL_CTX_sessions 3 ,
.Xr SSL_CTX_set_cert_store 3 ,
.Xr SSL_CTX_set_cert_verify_callback 3 ,
.Xr SSL_CTX_set_cipher_list 3 ,
.Xr SSL_CTX_set_client_CA_list 3 ,
.Xr SSL_CTX_set_client_cert_cb 3 ,
.Xr SSL_CTX_set_default_passwd_cb 3 ,
.Xr SSL_CTX_set_generate_session_id 3 ,
.Xr SSL_CTX_set_info_callback 3 ,
.Xr SSL_CTX_set_max_cert_list 3 ,
.Xr SSL_CTX_set_mode 3 ,
.Xr SSL_CTX_set_msg_callback 3 ,
.Xr SSL_CTX_set_options 3 ,
.Xr SSL_CTX_set_psk_client_callback 3 ,
.Xr SSL_CTX_set_quiet_shutdown 3 ,
.Xr SSL_CTX_set_session_cache_mode 3 ,
.Xr SSL_CTX_set_session_id_context 3 ,
.Xr SSL_CTX_set_ssl_version 3 ,
.Xr SSL_CTX_set_timeout 3 ,
.Xr SSL_CTX_set_tmp_dh_callback 3 ,
.Xr SSL_CTX_set_tmp_rsa_callback 3 ,
.Xr SSL_CTX_set_verify 3 ,
.Xr SSL_CTX_use_certificate 3 ,
.Xr SSL_CTX_use_psk_identity_hint 3 ,
.Xr SSL_do_handshake 3 ,
.Xr SSL_get_ciphers 3 ,
.Xr SSL_get_client_CA_list 3 ,
.Xr SSL_get_default_timeout 3 ,
.Xr SSL_get_error 3 ,
.Xr SSL_get_ex_data_X509_STORE_CTX_idx 3 ,
.Xr SSL_get_ex_new_index 3 ,
.Xr SSL_get_fd 3 ,
.Xr SSL_get_peer_cert_chain 3 ,
.Xr SSL_get_psk_identity 3 ,
.Xr SSL_get_rbio 3 ,
.Xr SSL_get_session 3 ,
.Xr SSL_get_SSL_CTX 3 ,
.Xr SSL_get_verify_result 3 ,
.Xr SSL_get_version 3 ,
.Xr SSL_library_init 3 ,
.Xr SSL_load_client_CA_file 3 ,
.Xr SSL_new 3 ,
.Xr SSL_pending 3 ,
.Xr SSL_read 3 ,
.Xr SSL_rstate_string 3 ,
.Xr SSL_SESSION_free 3 ,
.Xr SSL_SESSION_get_ex_new_index 3 ,
.Xr SSL_SESSION_get_time 3 ,
.Xr SSL_session_reused 3 ,
.Xr SSL_set_bio 3 ,
.Xr SSL_set_connect_state 3 ,
.Xr SSL_set_fd 3 ,
.Xr SSL_set_session 3 ,
.Xr SSL_set_shutdown 3 ,
.Xr SSL_shutdown 3 ,
.Xr SSL_state_string 3 ,
.Xr SSL_want 3 ,
.Xr SSL_write 3
.Sh HISTORY
The
.Nm
document appeared in OpenSSL 0.9.2.
|