summaryrefslogtreecommitdiff
path: root/lib/Net/SSLeay.pod
blob: e96133da7a4118aede05c20ad0e5747faaa01498 (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
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
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
=encoding utf-8

=head1 NAME

Net::SSLeay - Perl bindings for OpenSSL and LibreSSL

=head1 SYNOPSIS

    use Net::SSLeay qw(get_https post_https sslcat make_headers make_form);

    ($page) = get_https('www.bacus.pt', 443, '/');                 # Case 1

    ($page, $response, %reply_headers)
        = get_https('www.bacus.pt', 443, '/',                      # Case 2
            make_headers(User-Agent => 'Cryptozilla/5.0b1',
                         Referer    => 'https://www.bacus.pt')
          );

    ($page, $result, %headers)                                     # Case 2b
        = get_https('www.bacus.pt', 443, '/protected.html',
            make_headers(Authorization =>
                'Basic ' . MIME::Base64::encode("$user:$pass",''))
          );

    ($page, $response, %reply_headers)
        = post_https('www.bacus.pt', 443, '/foo.cgi', '',          # Case 3
            make_form(OK => '1', name => 'Sampo')
          );

    $reply = sslcat($host, $port, $request);                       # Case 4

    ($reply, $err, $server_cert) = sslcat($host, $port, $request); # Case 5

    $Net::SSLeay::trace = 2; # 0=no debugging, 1=ciphers, 2=trace, 3=dump data

    Net::SSLeay::initialize(); # Initialize ssl library once

=head1 DESCRIPTION

This module provides Perl bindings for libssl (an SSL/TLS API) and libcrypto (a
cryptography API).

=head1 COMPATIBILITY

Net::SSLeay supports the following libssl implementations:

=over

=item *

Any stable release of L<OpenSSL|https://www.openssl.org> in the 0.9.8 - 3.2
branches, except for OpenSSL 0.9.8 - 0.9.8b.

=item *

Any stable release of L<LibreSSL|https://www.libressl.org> in the 2.0 - 3.8
series, except for LibreSSL 3.2.2 and 3.2.3.

=back

Net::SSLeay may not function as expected with releases other than the ones
listed above due to libssl API incompatibilities, or, in the case of LibreSSL,
because of deviations from the libssl API.

Net::SSLeay is only as secure as the underlying libssl implementation you use.
Although Net::SSLeay maintains compatibility with old versions of OpenSSL and
LibreSSL, it is B<strongly recommended> that you use a version of OpenSSL or
LibreSSL that is supported by the OpenSSL/LibreSSL developers and/or your
operating system vendor. Many unsupported versions of OpenSSL and LibreSSL are
known to contain severe security vulnerabilities. Refer to the
L<OpenSSL Release Strategy|https://www.openssl.org/policies/releasestrat.html>
and L<LibreSSL Support Schedule|https://www.libressl.org/releases.html> for
information on which versions are currently supported.

The libssl API has changed significantly since OpenSSL 0.9.8: hundreds of
functions have been added, deprecated or removed in the intervening versions.
Although this documentation lists all of the functions and constants that
Net::SSLeay may expose, they will not be available for use if they are missing
from the underlying libssl implementation. Refer to the compatibility notes in
this documentation, as well as the OpenSSL/LibreSSL manual pages, for
information on which OpenSSL/LibreSSL versions support each function or
constant. At run-time, you can check whether a function or constant is exposed
before calling it using the following convention:

    if ( defined &Net::SSLeay::libssl_function ) {
        # libssl_function() (or SSL_libssl_function()) is available
        Net::SSLeay::libssl_function(...);
    }

=head1 OVERVIEW

L<Net::SSLeay> module basically comprise of:

=over

=item * High level functions for accessing web servers (by using HTTP/HTTPS)

=item * Low level API (mostly mapped 1:1 to openssl's C functions)

=item * Convenience functions (related to low level API but with more perl friendly interface)

=back

There is also a related module called L<Net::SSLeay::Handle> included in this
distribution that you might want to use instead. It has its own pod
documentation.

=head2 High level functions for accessing web servers

This module offers some high level convenience functions for accessing
web pages on SSL servers (for symmetry, the same API is offered for
accessing http servers, too), an C<sslcat()> function for writing your own
clients, and finally access to the SSL api of the SSLeay/OpenSSL package
so you can write servers or clients for more complicated applications.

For high level functions it is most convenient to import them into your
main namespace as indicated in the synopsis.

=head3 Basic set of functions

=over

=item * get_https

=item * post_https

=item * put_https

=item * head_https

=item * do_https

=item * sslcat

=item * https_cat

=item * make_form

=item * make_headers

=back

B<Case 1 (in SYNOPSIS)> demonstrates the typical invocation of get_https() to fetch an HTML
page from secure server. The first argument provides the hostname or IP
in dotted decimal notation of the remote server to contact. The second
argument is the TCP port at the remote end (your own port is picked
arbitrarily from high numbered ports as usual for TCP). The third
argument is the URL of the page without the host name part. If in
doubt consult the HTTP specifications at L<https://www.w3c.org>.

B<Case 2 (in SYNOPSIS)> demonstrates full fledged use of C<get_https()>. As can be seen,
C<get_https()> parses the response and response headers and returns them as
a list, which can be captured in a hash for later reference. Also a
fourth argument to C<get_https()> is used to insert some additional headers
in the request. C<make_headers()> is a function that will convert a list or
hash to such headers. By default C<get_https()> supplies C<Host> (to make
virtual hosting easy) and C<Accept> (reportedly needed by IIS) headers.

B<Case 2b (in SYNOPSIS)> demonstrates how to get a password protected page. Refer to
the HTTP protocol specifications for further details (e.g. RFC-2617).

B<Case 3 (in SYNOPSIS)> invokes C<post_https()> to submit a HTML/CGI form to a secure
server. The first four arguments are equal to C<get_https()> (note that
the empty string (C<''>) is passed as header argument).
The fifth argument is the
contents of the form formatted according to CGI specification.
Do not post UTF-8 data as content: use utf8::downgrade first. In this
case the helper function C<make_https()> is used to do the formatting,
but you could pass any string. C<post_https()> automatically adds
C<Content-Type> and C<Content-Length> headers to the request.

B<Case 4 (in SYNOPSIS)> shows the fundamental C<sslcat()> function (inspired in spirit by
the C<netcat> utility :-). It's your swiss army knife that allows you to
easily contact servers, send some data, and then get the response. You
are responsible for formatting the data and parsing the response -
C<sslcat()> is just a transport.

B<Case 5 (in SYNOPSIS)> is a full invocation of C<sslcat()> which allows the return of errors
as well as the server (peer) certificate.

The C<$trace> global variable can be used to control the verbosity of the
high level functions. Level 0 guarantees silence, level 1 (the default)
only emits error messages.

=head3 Alternate versions of high-level API

=over

=item * get_https3

=item * post_https3

=item * put_https3

=item * get_https4

=item * post_https4

=item * put_https4

=back

The above mentioned functions actually return the response headers as
a list, which only gets converted to hash upon assignment (this
assignment looses information if the same header occurs twice, as may
be the case with cookies). There are also other variants of the
functions that return unprocessed headers and that return a reference
to a hash.

    ($page, $response, @headers) = get_https('www.bacus.pt', 443, '/');
    for ($i = 0; $i < $#headers; $i+=2) {
        print "$headers[$i] = " . $headers[$i+1] . "\n";
    }

    ($page, $response, $headers, $server_cert)
        = get_https3('www.bacus.pt', 443, '/');
    print "$headers\n";

    ($page, $response, $headers_ref)
        = get_https4('www.bacus.pt', 443, '/');
    for $k (sort keys %{$headers_ref}) {
        for $v (@{$$headers_ref{$k}}) {
            print "$k = $v\n";
        }
    }

All of the above code fragments accomplish the same thing: display all
values of all headers. The API functions ending in "3" return the
headers simply as a scalar string and it is up to the application to
split them up. The functions ending in "4" return a reference to
a hash of arrays (see L<perlref> and L<perllol> if you are
not familiar with complex perl data structures). To access a single value
of such a header hash you would do something like

    print $$headers_ref{COOKIE}[0];

Variants 3 and 4 also allow you to discover the server certificate
in case you would like to store or display it, e.g.

    ($p, $resp, $hdrs, $server_cert) = get_https3('www.bacus.pt', 443, '/');
    if (!defined($server_cert) || ($server_cert == 0)) {
        warn "Subject Name: undefined, Issuer  Name: undefined";
    } else {
        warn sprintf('Subject Name: %s Issuer  Name: %s',
            Net::SSLeay::X509_NAME_oneline(
                Net::SSLeay::X509_get_subject_name($server_cert)),
            Net::SSLeay::X509_NAME_oneline(
                Net::SSLeay::X509_get_issuer_name($server_cert))
        );
    }

Beware that this method only allows after the fact verification of
the certificate: by the time C<get_https3()> has returned the https
request has already been sent to the server, whether you decide to
trust it or not. To do the verification correctly you must either
employ the OpenSSL certificate verification framework or use
the lower level API to first connect and verify the certificate
and only then send the http data. See the implementation of C<ds_https3()>
for guidance on how to do this.

=head3 Using client certificates

Secure web communications are encrypted using symmetric crypto keys
exchanged using encryption based on the certificate of the
server. Therefore in all SSL connections the server must have a
certificate. This serves both to authenticate the server to the
clients and to perform the key exchange.

Sometimes it is necessary to authenticate the client as well. Two
options are available: HTTP basic authentication and a client side
certificate. The basic authentication over HTTPS is actually quite
safe because HTTPS guarantees that the password will not travel in
the clear. Never-the-less, problems like easily guessable passwords
remain. The client certificate method involves authentication of the
client at the SSL level using a certificate. For this to work, both the
client and the server have certificates (which typically are
different) and private keys.

The API functions outlined above accept additional arguments that
allow one to supply the client side certificate and key files. The
format of these files is the same as used for server certificates and
the caveat about encrypting private keys applies.

    ($page, $result, %headers)                                     # 2c
        = get_https('www.bacus.pt', 443, '/protected.html',
            make_headers(Authorization =>
                'Basic ' . MIME::Base64::encode("$user:$pass",'')),
            '', $mime_type6, $path_to_crt7, $path_to_key8
          );

    ($page, $response, %reply_headers)
        = post_https('www.bacus.pt', 443, '/foo.cgi',              # 3b
            make_headers('Authorization' =>
                'Basic ' . MIME::Base64::encode("$user:$pass",'')),
            make_form(OK   => '1', name => 'Sampo'),
            $mime_type6, $path_to_crt7, $path_to_key8
          );

B<Case 2c (in SYNOPSIS)> demonstrates getting a password protected page that also requires
a client certificate, i.e. it is possible to use both authentication
methods simultaneously.

B<Case 3b (in SYNOPSIS)> is a full blown POST to a secure server that requires both password
authentication and a client certificate, just like in case 2c.

Note: The client will not send a certificate unless the server requests one.
This is typically achieved by setting the verify mode to C<VERIFY_PEER> on the
server:

    Net::SSLeay::set_verify($ssl, Net::SSLeay::VERIFY_PEER, 0);

See C<perldoc ~openssl/doc/ssl/SSL_CTX_set_verify.pod> for a full description.

=head3 Working through a web proxy

=over

=item * set_proxy

=back

C<Net::SSLeay> can use a web proxy to make its connections. You need to
first set the proxy host and port using C<set_proxy()> and then just
use the normal API functions, e.g:

    Net::SSLeay::set_proxy('gateway.myorg.com', 8080);
    ($page) = get_https('www.bacus.pt', 443, '/');

If your proxy requires authentication, you can supply a username and
password as well

    Net::SSLeay::set_proxy('gateway.myorg.com', 8080, 'joe', 'salainen');
    ($page, $result, %headers)
        = get_https('www.bacus.pt', 443, '/protected.html',
            make_headers(Authorization =>
                'Basic ' . MIME::Base64::encode("susie:pass",''))
          );

This example demonstrates the case where we authenticate to the proxy as
C<"joe"> and to the final web server as C<"susie">. Proxy authentication
requires the C<MIME::Base64> module to work.

=head3 HTTP (without S) API

=over

=item * get_http

=item * post_http

=item * tcpcat

=item * get_httpx

=item * post_httpx

=item * tcpxcat

=back

Over the years it has become clear that it would be convenient to use
the light-weight flavour API of C<Net::SSLeay> for normal HTTP as well (see
C<LWP> for the heavy-weight object-oriented approach). In fact it would be
nice to be able to flip https on and off on the fly. Thus regular HTTP
support was evolved.

    use Net::SSLeay qw(get_http post_http tcpcat
                       get_httpx post_httpx tcpxcat
                       make_headers make_form);

    ($page, $result, %headers)
        = get_http('www.bacus.pt', 443, '/protected.html',
            make_headers(Authorization =>
                'Basic ' . MIME::Base64::encode("$user:$pass",''))
          );

    ($page, $response, %reply_headers)
        = post_http('www.bacus.pt', 443, '/foo.cgi', '',
            make_form(OK => '1', name => 'Sampo')
          );

    ($reply, $err) = tcpcat($host, $port, $request);

    ($page, $result, %headers)
        = get_httpx($usessl, 'www.bacus.pt', 443, '/protected.html',
            make_headers(Authorization =>
                'Basic ' . MIME::Base64::encode("$user:$pass",''))
          );

    ($page, $response, %reply_headers)
        = post_httpx($usessl, 'www.bacus.pt', 443, '/foo.cgi', '',
            make_form(OK => '1',  name => 'Sampo')
          );

    ($reply, $err, $server_cert) = tcpxcat($usessl, $host, $port, $request);

As can be seen, the C<"x"> family of APIs takes as the first argument a flag
which indicates whether SSL is used or not.

=head2 Certificate verification and Certificate Revocation Lists (CRLs)

OpenSSL supports the ability to verify peer certificates. It can also
optionally check the peer certificate against a Certificate Revocation
List (CRL) from the certificates issuer. A CRL is a file, created by
the certificate issuer that lists all the certificates that it
previously signed, but which it now revokes. CRLs are in PEM format.

You can enable C<Net::SSLeay CRL> checking like this:

    &Net::SSLeay::X509_STORE_set_flags(
        &Net::SSLeay::CTX_get_cert_store($ssl),
        &Net::SSLeay::X509_V_FLAG_CRL_CHECK
    );

After setting this flag, if OpenSSL checks a peer's certificate, then
it will attempt to find a CRL for the issuer. It does this by looking
for a specially named file in the search directory specified by
CTX_load_verify_locations.  CRL files are named with the hash of the
issuer's subject name, followed by C<.r0>, C<.r1> etc.  For example
C<ab1331b2.r0>, C<ab1331b2.r1>. It will read all the .r files for the
issuer, and then check for a revocation of the peer certificate in all
of them.  (You can also force it to look in a specific named CRL
file., see below).  You can find out the hash of the issuer subject
name in a CRL with

    openssl crl -in crl.pem -hash -noout

If the peer certificate does not pass the revocation list, or if no
CRL is found, then the handshaking fails with an error.

You can also force OpenSSL to look for CRLs in one or more arbitrarily
named files.

    my $bio = Net::SSLeay::BIO_new_file($crlfilename, 'r');
    my $crl = Net::SSLeay::PEM_read_bio_X509_CRL($bio);
    if ($crl) {
        Net::SSLeay::X509_STORE_add_crl(
               Net::SSLeay::CTX_get_cert_store($ssl, $crl)
        );
    } else {
        # error reading CRL....
    }

Usually the URLs where you can download the CRLs is contained in the certificate
itself and you can extract them with

    my @url = Net::SSLeay::P_X509_get_crl_distribution_points($cert);

But there is no automatic downloading of the CRLs and often these CRLs are too
huge to just download them to verify a single certificate.
Also, these CRLs are often in DER format which you need to convert to PEM before
you can use it:

    openssl crl -in crl.der -inform der -out crl.pem

So as an alternative for faster and timely revocation checks you better use
the Online Status Revocation Protocol (OCSP).

=head2 Certificate verification and Online Status Revocation Protocol (OCSP)

While checking for revoked certificates is possible and fast with Certificate
Revocation Lists, you need to download the complete and often huge list before
you can verify a single certificate.

A faster way is to ask the CA to check the revocation of just a single or a few
certificates using OCSP. Basically you generate for each certificate an
OCSP_CERTID based on the certificate itself and its issuer, put the ids
together into an OCSP_REQUEST and send the request to the URL given in the
certificate.

As a result you get back an OCSP_RESPONSE and need to check the status of the
response, check that it is valid (e.g. signed by the CA) and finally extract the
information about each OCSP_CERTID to find out if the certificate is still valid
or got revoked.

With Net::SSLeay this can be done like this:

    # get id(s) for given certs, like from get_peer_certificate
    # or get_peer_cert_chain. This will croak if
    # - one tries to make an OCSP_CERTID for a self-signed certificate
    # - the issuer of the certificate cannot be found in the SSL objects
    #   store, nor in the current certificate chain
    my $cert = Net::SSLeay::get_peer_certificate($ssl);
    my $id = eval { Net::SSLeay::OCSP_cert2ids($ssl,$cert) };
    die "failed to make OCSP_CERTID: $@" if $@;

    # create OCSP_REQUEST from id(s)
    # Multiple can be put into the same request, if the same OCSP responder
    # is responsible for them.
    my $req = Net::SSLeay::OCSP_ids2req($id);

    # determine URI of OCSP responder
    my $uri = Net::SSLeay::P_X509_get_ocsp_uri($cert);

    # Send stringified OCSP_REQUEST with POST to $uri.
    # We can ignore certificate verification for https, because the OCSP
    # response itself is signed.
    my $ua = HTTP::Tiny->new(verify_SSL => 0);
    my $res = $ua->request( 'POST',$uri, {
        headers => { 'Content-type' => 'application/ocsp-request' },
        content => Net::SSLeay::i2d_OCSP_REQUEST($req)
    });
    my $content = $res && $res->{success} && $res->{content}
        or die "query failed";

    # Extract OCSP_RESPONSE.
    # this will croak if the string is not an OCSP_RESPONSE
    my $resp = eval { Net::SSLeay::d2i_OCSP_RESPONSE($content) };

    # Check status of response.
    my $status = Net::SSLeay::OCSP_response_status($resp);
    if ($status != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL()) {
        die "OCSP response failed: " .
            Net::SSLeay::OCSP_response_status_str($status);
    }

    # Verify signature of response and if nonce matches request.
    # This will croak if there is a nonce in the response, but it does not match
    # the request. It will return false if the signature could not be verified,
    # in which case details can be retrieved with Net::SSLeay::ERR_get_error.
    # It will not complain if the response does not contain a nonce, which is
    # usually the case with pre-signed responses.
    if ( ! eval { Net::SSLeay::OCSP_response_verify($ssl,$resp,$req) }) {
        die "OCSP response verification failed";
    }

    # Extract information from OCSP_RESPONSE for each of the ids.

    # If called in scalar context it will return the time (as time_t), when the
    # next update is due (minimum of all successful responses inside $resp). It
    # will croak on the following problems:
    # - response is expired or not yet valid
    # - no response for given OCSP_CERTID
    # - certificate status is not good (e.g. revoked or unknown)
    if ( my $nextupd = eval { Net::SSLeay::OCSP_response_results($resp,$id) }) {
        warn "certificate is valid, next update in " .
            ($nextupd-time()) . " seconds\n";
    } else {
        die "certificate is not valid: $@";
    }

    # But in array context it will return detailed information about each given
    # OCSP_CERTID instead croaking on errors:
    # if no @ids are given it will return information about all single responses
    # in the OCSP_RESPONSE
    my @results = Net::SSLeay::OCSP_response_results($resp,@ids);
    for my $r (@results) {
        print Dumper($r);
        # @results are in the same order as the @ids and contain:
        # $r->[0] - OCSP_CERTID
        # $r->[1] - undef if no error (certificate good) OR error message as string
        # $r->[2] - hash with details:
        #   thisUpdate - time_t of this single response
        #   nextUpdate - time_t when update is expected
        #   statusType - integer:
        #      V_OCSP_CERTSTATUS_GOOD(0)
        #      V_OCSP_CERTSTATUS_REVOKED(1)
        #      V_OCSP_CERTSTATUS_UNKNOWN(2)
        #   revocationTime - time_t (only if revoked)
        #   revocationReason - integer (only if revoked)
        #   revocationReason_str - reason as string (only if revoked)
    }

To further speed up certificate revocation checking one can use a TLS extension
to instruct the server to staple the OCSP response:

    # set TLS extension before doing SSL_connect
    Net::SSLeay::set_tlsext_status_type($ssl,
        Net::SSLeay::TLSEXT_STATUSTYPE_ocsp());

    # setup callback to verify OCSP response
    my $cert_valid = undef;
    Net::SSLeay::CTX_set_tlsext_status_cb($context,sub {
        my ($ssl,$resp) = @_;
        if (!$resp) {
            # Lots of servers don't return an OCSP response.
            # In this case we must check the OCSP status outside the SSL
            # handshake.
            warn "server did not return stapled OCSP response\n";
            return 1;
        }
        # verify status
        my $status = Net::SSLeay::OCSP_response_status($resp);
        if ($status != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL()) {
            warn "OCSP response failure: $status\n";
            return 1;
        }
        # verify signature - we have no OCSP_REQUEST here to check nonce
        if (!eval { Net::SSLeay::OCSP_response_verify($ssl,$resp) }) {
            warn "OCSP response verify failed\n";
            return 1;
        }
        # check if the certificate is valid
        # we should check here against the peer_certificate
        my $cert = Net::SSLeay::get_peer_certificate();
        my $certid = eval { Net::SSLeay::OCSP_cert2ids($ssl,$cert) } or do {
            warn "cannot get certid from cert: $@";
            $cert_valid = -1;
            return 1;
        };

        if ( $nextupd = eval {
            Net::SSLeay::OCSP_response_results($resp,$certid) }) {
            warn "certificate not revoked\n";
            $cert_valid = 1;
        } else {
            warn "certificate not valid: $@";
            $cert_valid = 0;
        }
    });

    # do SSL handshake here
    # ....
    # check if certificate revocation was checked already
    if ( ! defined $cert_valid) {
        # check revocation outside of SSL handshake by asking OCSP responder
        ...
    } elsif ( ! $cert_valid ) {
        die "certificate not valid - closing SSL connection";
    } elsif ( $cert_valid<0 ) {
        die "cannot verify certificate revocation - self-signed ?";
    } else {
        # everything fine
        ...
    }

=head2 Using Net::SSLeay in multi-threaded applications

B<IMPORTANT: versions 1.42 or earlier are not thread-safe!>

Net::SSLeay module implements all necessary stuff to be ready for multi-threaded
environment - it requires openssl-0.9.7 or newer. The implementation fully follows thread safety related requirements
of openssl library(see L<https://www.openssl.org/docs/manmaster/man3/threads.html>).

If you are about to use Net::SSLeay (or any other module based on Net::SSLeay) in multi-threaded
perl application it is recommended to follow this best-practice:

=head3 Initialization

Load and initialize Net::SSLeay module in the main thread:

    use threads;
    use Net::SSLeay;

    Net::SSLeay::load_error_strings();
    Net::SSLeay::SSLeay_add_ssl_algorithms();
    Net::SSLeay::randomize();

    sub do_master_job {
        # ... call whatever from Net::SSLeay
    }

    sub do_worker_job {
        # ... call whatever from Net::SSLeay
    }

    # start threads
    my $master  = threads->new(\&do_master_job, 'param1', 'param2');
    my @workers = threads->new(\&do_worker_job, 'arg1', 'arg2') for (1..10);

    # waiting for all threads to finish
    $_->join() for (threads->list);

NOTE: Openssl's C<int SSL_library_init(void)> function (which is also aliased as
C<SSLeay_add_ssl_algorithms>, C<OpenSSL_add_ssl_algorithms> and C<add_ssl_algorithms>)
is not re-entrant and multiple calls can cause a crash in threaded application.
Net::SSLeay implements flags preventing repeated calls to this function,
therefore even multiple initialization via Net::SSLeay::SSLeay_add_ssl_algorithms()
should work without trouble.

=head3 Using callbacks

Do not use callbacks across threads (the module blocks cross-thread callback operations
and throws a warning). Always do the callback setup, callback use and callback destruction
within the same thread.

=head3 Using openssl elements

All openssl elements (X509, SSL_CTX, ...) can be directly passed between threads.

    use threads;
    use Net::SSLeay;

    Net::SSLeay::load_error_strings();
    Net::SSLeay::SSLeay_add_ssl_algorithms();
    Net::SSLeay::randomize();

    sub do_job {
        my $context = shift;
        Net::SSLeay::CTX_set_default_passwd_cb($context, sub { "secret" });
        # ...
    }

    my $c = Net::SSLeay::CTX_new();
    threads->create(\&do_job, $c);

Or:

    use threads;
    use Net::SSLeay;

    my $context; # does not need to be 'shared'

    Net::SSLeay::load_error_strings();
    Net::SSLeay::SSLeay_add_ssl_algorithms();
    Net::SSLeay::randomize();

    sub do_job {
        Net::SSLeay::CTX_set_default_passwd_cb($context, sub { "secret" });
        # ...
    }

    $context = Net::SSLeay::CTX_new();
    threads->create(\&do_job);

=head3 Using other perl modules based on Net::SSLeay

It should be fine to use any other module based on L<Net::SSLeay> (like L<IO::Socket::SSL>)
in multi-threaded applications. It is generally recommended to do any global initialization
of such a module in the main thread before calling C<< threads->new(..) >> or
C<< threads->create(..) >> but it might differ module by module.

To be safe you can load and init Net::SSLeay explicitly in the main thread:

    use Net::SSLeay;
    use Other::SSLeay::Based::Module;

    Net::SSLeay::load_error_strings();
    Net::SSLeay::SSLeay_add_ssl_algorithms();
    Net::SSLeay::randomize();

Or even safer:

    use Net::SSLeay;
    use Other::SSLeay::Based::Module;

    BEGIN {
        Net::SSLeay::load_error_strings();
        Net::SSLeay::SSLeay_add_ssl_algorithms();
        Net::SSLeay::randomize();
    }

=head3 Combining Net::SSLeay with other modules linked with openssl

B<BEWARE: This might be a big trouble! This is not guaranteed be thread-safe!>

There are many other (XS) modules linked directly to openssl library (like L<Crypt::SSLeay>).

As it is expected that also "another" module will call C<SSLeay_add_ssl_algorithms> at some point
we have again a trouble with multiple openssl initialization by Net::SSLeay and "another" module.

As you can expect Net::SSLeay is not able to avoid multiple initialization of openssl library
called by "another" module, thus you have to handle this on your own (in some cases it might
not be possible at all to avoid this).

=head3 Threading with get_https and friends

The convenience functions get_https, post_https etc all initialize the SSL library by calling
Net::SSLeay::initialize which does the conventional library initialization:

    Net::SSLeay::load_error_strings();
    Net::SSLeay::SSLeay_add_ssl_algorithms();
    Net::SSLeay::randomize();

Net::SSLeay::initialize initializes the SSL library at most once.
You can override the Net::SSLeay::initialize function if you desire
some other type of initialization behaviour by get_https and friends.
You can call Net::SSLeay::initialize from your own code if you desire this conventional library initialization.

=head2 Convenience routines

To be used with Low level API

    Net::SSLeay::randomize($rn_seed_file,$additional_seed);
    Net::SSLeay::set_cert_and_key($ctx, $cert_path, $key_path);
    $cert = Net::SSLeay::dump_peer_certificate($ssl);
    Net::SSLeay::ssl_write_all($ssl, $message) or die "ssl write failure";
    $got = Net::SSLeay::ssl_read_all($ssl) or die "ssl read failure";

    $got = Net::SSLeay::ssl_read_CRLF($ssl [, $max_length]);
    $got = Net::SSLeay::ssl_read_until($ssl [, $delimit [, $max_length]]);
    Net::SSLeay::ssl_write_CRLF($ssl, $message);

=over

=item * randomize

seeds the openssl PRNG with C</dev/urandom> (see the top of C<SSLeay.pm>
for how to change or configure this) and optionally with user provided
data. It is very important to properly seed your random numbers, so
do not forget to call this. The high level API functions automatically
call C<randomize()> so it is not needed with them. See also caveats.

=item * set_cert_and_key

takes two file names as arguments and sets
the certificate and private key to those. This can be used to
set either server certificates or client certificates.

=item * dump_peer_certificate

allows you to get a plaintext description of the
certificate the peer (usually the server) presented to us.

=item * ssl_read_all

see ssl_write_all (below)

=item * ssl_write_all

C<ssl_read_all()> and C<ssl_write_all()> provide true blocking semantics for
these operations (see limitation, below, for explanation). These are
much preferred to the low level API equivalents (which implement BSD
blocking semantics). The message argument to C<ssl_write_all()> can be
a reference. This is helpful to avoid unnecessary copying when writing
something big, e.g:

    $data = 'A' x 1000000000;
    Net::SSLeay::ssl_write_all($ssl, \$data) or die "ssl write failed";

=item * ssl_read_CRLF

uses C<ssl_read_all()> to read in a line terminated with a
carriage return followed by a linefeed (CRLF).  The CRLF is included in
the returned scalar.

=item * ssl_read_until

uses C<ssl_read_all()> to read from the SSL input
stream until it encounters a programmer specified delimiter.
If the delimiter is undefined, C<$/> is used.  If C<$/> is undefined,
C<\n> is used.  One can optionally set a maximum length of bytes to read
from the SSL input stream.

=item * ssl_write_CRLF

writes C<$message> and appends CRLF to the SSL output stream.

=back

=head2 Initialization

In order to use the low level API you should start your programs with
the following incantation:

    use Net::SSLeay qw(die_now die_if_ssl_error);
    Net::SSLeay::load_error_strings();
    Net::SSLeay::SSLeay_add_ssl_algorithms();    # Important!
    Net::SSLeay::ENGINE_load_builtin_engines();  # If you want built-in engines
    Net::SSLeay::ENGINE_register_all_complete(); # If you want built-in engines
    Net::SSLeay::randomize();

=head2 Error handling functions

I can not emphasize the need to check for error enough. Use these
functions even in the most simple programs, they will reduce debugging
time greatly. Do not ask questions on the mailing list without having
first sprinkled these in your code.

=over

=item * die_now

=item * die_if_ssl_error

C<die_now()> and C<die_if_ssl_error()> are used to conveniently print the SSLeay error
stack when something goes wrong:

    Net::SSLeay::connect($ssl) or die_now("Failed SSL connect ($!)");

    Net::SSLeay::write($ssl, "foo") or die_if_ssl_error("SSL write ($!)");

=item * print_errs

You can also use C<Net::SSLeay::print_errs()> to dump the error stack without
exiting the program. As can be seen, your code becomes much more readable
if you import the error reporting functions into your main name space.

=back

=head2 Sockets

Perl uses file handles for all I/O. While SSLeay has a quite flexible BIO
mechanism and perl has an evolved PerlIO mechanism, this module still
sticks to using file descriptors. Thus to attach SSLeay to a socket you
should use C<fileno()> to extract the underlying file descriptor:

    Net::SSLeay::set_fd($ssl, fileno(S));   # Must use fileno

You should also set C<$|> to 1 to eliminate STDIO buffering so you do not
get confused if you use perl I/O functions to manipulate your socket
handle.

If you need to C<select(2)> on the socket, go right ahead, but be warned
that OpenSSL does some internal buffering so SSL_read does not always
return data even if the socket selected for reading (just keep on
selecting and trying to read). C<Net::SSLeay> is no different from the
C language OpenSSL in this respect.

=head2 Callbacks

You can establish a per-context verify callback function something like this:

    sub verify {
        my ($ok, $x509_store_ctx) = @_;
        print "Verifying certificate...\n";
        # ...
        return $ok;
    }

It is used like this:

    Net::SSLeay::set_verify ($ssl, Net::SSLeay::VERIFY_PEER, \&verify);

Per-context callbacks for decrypting private keys are implemented.

    Net::SSLeay::CTX_set_default_passwd_cb($ctx, sub { "top-secret" });
    Net::SSLeay::CTX_use_PrivateKey_file($ctx, "key.pem",
                                         Net::SSLeay::FILETYPE_PEM)
        or die "Error reading private key";
    Net::SSLeay::CTX_set_default_passwd_cb($ctx, undef);

If Hello Extensions are supported by your OpenSSL,
a session secret callback can be set up to be called when a session secret is set
by openssl.

Establish it like this:

    Net::SSLeay::set_session_secret_cb($ssl, \&session_secret_cb, $somedata);

It will be called like this:

    sub session_secret_cb {
        my ($secret, \@cipherlist, \$preferredcipher, $somedata) = @_;
    }

No other callbacks are implemented. You do not need to use any
callback for simple (i.e. normal) cases where the SSLeay built-in
verify mechanism satisfies your needs.

It is required to reset these callbacks to undef immediately after use to prevent
memory leaks, thread safety problems and crashes on exit that
can occur if different threads set different callbacks.

If you want to use callback stuff, see examples/callback.pl! It's the
only one I am able to make work reliably.

=head2 Low level API

In addition to the high level functions outlined above, this module
contains straight-forward access to CRYPTO and SSL parts of OpenSSL C API.

See the C<*.h> headers from OpenSSL C distribution for a list of low level
SSLeay functions to call (check SSLeay.xs to see if some function has been
implemented). The module strips the initial C<"SSL_"> off of the SSLeay names.
Generally you should use C<Net::SSLeay::> in its place.

Note that some functions are prefixed with C<"P_"> - these are very close to
the original API however contain some kind of a wrapper making its interface
more perl friendly.

For example:

In C:

    #include <ssl.h>

    err = SSL_set_verify (ssl, SSL_VERIFY_CLIENT_ONCE, &your_call_back_here);

In Perl:

    use Net::SSLeay;

    $err = Net::SSLeay::set_verify ($ssl,
                                    Net::SSLeay::VERIFY_CLIENT_ONCE,
                                    \&your_call_back_here);

If the function does not start with C<SSL_> you should use the full
function name, e.g.:

    $err = Net::SSLeay::ERR_get_error;

The following new functions behave in perlish way:

    $got = Net::SSLeay::read($ssl);
                                # Performs SSL_read, but returns $got
                                # resized according to data received.
                                # Returns undef on failure.

    Net::SSLeay::write($ssl, $foo) || die;
                                # Performs SSL_write, but automatically
                                # figures out the size of $foo

=head3 Low level API: Version and library information related functions

=over

=item * OpenSSL_version_num and SSLeay

B<COMPATIBILITY:> SSLeay() is not available in Net-SSLeay-1.42 and
before. SSLeay() was made an alias of OpenSSL_version_num() in OpenSSL
1.1.0 and LibreSSL 2.7.0.

B<COMPATIBILITY:> OpenSSL_version_num() requires at least
Net-SSLeay-1.82 with OpenSSL 1.1.0, or Net-SSLeay-1.88 with LibreSSL
2.7.0.

Both functions return OPENSSL_VERSION_NUMBER constant (numeric) as
defined by the underlying OpenSSL or LibreSSL library.

    my $ver_number = Net::SSLeay::SSLeay();
    # or
    my $ver_number = Net::SSLeay::OpenSSL_version_num();
    # returns: OPENSSL_VERSION_NUMBER constant

    # OpenSSL version numbering is:
    # 0x00903100 => openssl-0.9.3
    # 0x00904100 => openssl-0.9.4
    # 0x00905100 => openssl-0.9.5
    # 0x0090600f => openssl-0.9.6
    # 0x0090601f => openssl-0.9.6a
    # ...
    # 0x009060df => openssl-0.9.6m
    # 0x0090700f => openssl-0.9.7
    # 0x0090701f => openssl-0.9.7a
    # ...
    # 0x009070df => openssl-0.9.7m
    # 0x0090800f => openssl-0.9.8
    # 0x0090801f => openssl-0.9.8a
    # ...
    # 0x0090821f => openssl-0.9.8zh
    # 0x1000000f => openssl-1.0.0
    # ...
    # 0x1000014f => openssl-1.0.0t
    # 0x1000100f => openssl-1.0.1
    # ...
    # 0x1000115f => openssl-1.0.1u
    # 0x1000200f => openssl-1.0.2
    # ...
    # 0x1000215f => openssl-1.0.2u
    # 0x1010000f => openssl-1.1.0
    # ...
    # 0x101000cf => openssl-1.1.0l
    # 0x1010100f => openssl-1.1.1
    # ...
    # 0x1010117f => openssl-1.1.1w
    # 0x30000000 => openssl-3.0.0
    # ...
    # 0x300000c0 => openssl-3.0.12
    # 0x30100000 => openssl-3.1.0
    # ...
    # 0x30100040 => openssl-3.1.4
    # 0x30200000 => openssl-3.2.0

    # Note that OpenSSL 3.0.0 and later do not set the status nibble in the
    # least significant octet to f.

    # LibreSSL returns 0x20000000 always:
    # 0x20000000 => libressl-2.2.1
    # ...
    # 0x20000000 => libressl-3.8.2

You can use the version number like this when you know that the
underlying library is OpenSSL:

    if (Net::SSLeay::SSLeay() < 0x0090800f) {
        die "You need OpenSSL 0.9.8 or higher";
    }

LibresSSL 2.2.2 and later define constant LIBRESSL_VERSION_NUMBER that
gives the LibreSSL version number. The format is the same that OpenSSL
uses with OPENSSL_VERSION_NUMBER. You can do this if you need to
check that the underlying library is LibreSSL and it's recent enough:

    if (Net::SSLeay::SSLeay() != 0x20000000 ||
            Net::SSLeay::LIBRESSL_VERSION_NUMBER() < 0x3040200f) {
        die "You need LibreSSL. Version 3.4.2 or higher";
    }

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OpenSSL_version_num.html>

See OpenSSL 1.1.1 and earlier documentation for the details of status
nibble and the format interpretation.

=item * SSLeay_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Returns different strings depending on $type.

    my $ver_string = Net::SSLeay::SSLeay_version($type);
    # $type
    #   SSLEAY_VERSION  - e.g. 'OpenSSL 1.0.0d 8 Feb 2011'
    #   SSLEAY_CFLAGS   - e.g. 'compiler: gcc -D_WINDLL -DOPENSSL_USE_APPLINK .....'
    #   SSLEAY_BUILT_ON - e.g. 'built on: Fri May  6 00:00:46 GMT 2011'
    #   SSLEAY_PLATFORM - e.g. 'platform: mingw'
    #   SSLEAY_DIR      - e.g. 'OPENSSLDIR: "z:/...."'
    #
    # returns: string

    Net::SSLeay::SSLeay_version();
    # is equivalent to
    Net::SSLeay::SSLeay_version(SSLEAY_VERSION);

OpenSSL 1.1.0 changed SSLeay_version() to an alias of
OpenSSL_version(). To ensure correct functionality with LibreSSL, use
SSLEAY_* constants with SSLeay_version() and OPENSSL_* constants with
OpenSSL_version().

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OpenSSL_version.html>

OpenSSL website no longer has a manual page for SSLeay_version().

=item * OpenSSL_version

B<COMPATIBILITY:> requires at least Net-SSLeay-1.82 with OpenSSL
1.1.0, or Net-SSLeay-1.88 with LibreSSL 2.7.0.

Returns different strings depending on $t. Available $t constants
depend on the library version.

    my $ver_string = Net::SSLeay::OpenSSL_version($t);
    # $t
    #   OPENSSL_VERSION     - e.g. 'OpenSSL 1.1.0g  2 Nov 2017'
    #   OPENSSL_CFLAGS      - e.g. 'compiler: cc -DDSO_DLFCN -DHAVE_DLFCN_H .....'
    #   OPENSSL_BUILT_ON    - e.g. 'built on: reproducible build, date unspecified'
    #   OPENSSL_PLATFORM    - e.g. 'platform: darwin64-x86_64-cc'
    #   OPENSSL_DIR         - e.g. 'OPENSSLDIR: "/opt/openssl-1.1.0g"'
    #   OPENSSL_ENGINES_DIR - e.g. 'ENGINESDIR: "/opt/openssl-1.1.0g/lib/engines-1.1"'
    #
    # returns: string

    Net::SSLeay::OpenSSL_version();
    # is equivalent to
    Net::SSLeay::OpenSSL_version(OPENSSL_VERSION);

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OpenSSL_version.html>

=item * OPENSSL_info

B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and before; requires at least OpenSSL 3.0.0-alpha1

Returns different strings depending on $t. Available $t constants
depend on the library version.

    my $info_string = Net::SSLeay::OPENSSL_info($t);
    # $t
    #   OPENSSL_INFO_CONFIG_DIR - e.g. '/opt/openssl-3.0.1'
    #   OPENSSL_INFO_...
    #
    # returns: string

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OPENSSL_info.html>

=item * OPENSSL_version_major, OPENSSL_version_minor and OPENSSL_version_patch

B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and before; requires at least OpenSSL 3.0.0-alpha1, not in LibreSSL

Return constants OPENSSL_VERSION_MAJOR, OPENSSL_VERSION_MINOR and OPENSSL_VERSION_PATCH, respectively.

    my $major = Net::SSLeay::OPENSSL_version_major();
    my $minor = Net::SSLeay::OPENSSL_version_minor();
    my $patch = Net::SSLeay::OPENSSL_version_patch();
    #
    # return: integer

For example with OpenSSL 3.0.1, $major is 3, $minor is 0 and $patch is 1.

Note: the constants record Net::SSLeay compile time values whereas the
three functions return values from the library. Typically these are
the same, but they can be different if the library version is updated
but Net::SSLeay is not re-compiled. See the OpenSSL and LibreSSL
API/ABI compatibility statements for more information.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OPENSSL_version_major.html>

=item * OPENSSL_version_pre_release

B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and before; requires at least OpenSSL 3.0.0-alpha1, not in LibreSSL

Return constant string defined by C macro OPENSSL_VERSION_PRE_RELEASE.

    my $pre_release = Net::SSLeay::OPENSSL_version_pre_release();
    #
    # returns: string (For example: "-alpha3" or "" for a release version)

When the macro is not defined, an empty string is returned instead.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OPENSSL_version_pre_release.html>

=item * OPENSSL_version_build_metadata

B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and before; requires at least OpenSSL 3.0.0-alpha1, not in LibreSSL

Return constant string defined by C macro OPENSSL_VERSION_BUILD_METADATA.

    my $metadata = Net::SSLeay::OPENSSL_version_build_metadata();
    #
    # returns: string (For example: "+fips" or "")

When the macro is not defined, an empty string is returned instead.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OPENSSL_version_build_metadata.html>

=back

=head3 Low level API: Initialization related functions

=over

=item * library_init

Initialize SSL library by registering algorithms.

    my $rv = Net::SSLeay::library_init();

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_library_init.html>

While the original function from OpenSSL always returns 1, Net::SSLeay adds a
wrapper around it to make sure that the OpenSSL function is only called once.
Thus the function will return 1 if initialization was done and 0 if not, i.e. if
initialization was done already before.

=item * add_ssl_algorithms

The alias for L</library_init>

    Net::SSLeay::add_ssl_algorithms();

=item * OpenSSL_add_ssl_algorithms

The alias for L</library_init>

    Net::SSLeay::OpenSSL_add_ssl_algorithms();

=item * SSLeay_add_ssl_algorithms

The alias for L</library_init>

    Net::SSLeay::SSLeay_add_ssl_algorithms();

=item * load_error_strings

Registers the error strings for all libcrypto + libssl related functions.

    Net::SSLeay::load_error_strings();
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ERR_load_crypto_strings.html>

=item * ERR_load_crypto_strings

Registers the error strings for all libcrypto functions. No need to call this function if you have already called L</load_error_strings>.

    Net::SSLeay::ERR_load_crypto_strings();
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ERR_load_crypto_strings.html>

=item * ERR_load_RAND_strings

Registers the error strings for RAND related functions. No need to call this function if you have already called L</load_error_strings>.

    Net::SSLeay::ERR_load_RAND_strings();
    #
    # returns: no return value

=item * ERR_load_SSL_strings

Registers the error strings for SSL related functions. No need to call this function if you have already called L</load_error_strings>.

    Net::SSLeay::ERR_load_SSL_strings();
    #
    # returns: no return value

=item * OpenSSL_add_all_algorithms

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Add algorithms to internal table.

    Net::SSLeay::OpenSSL_add_all_algorithms();
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OpenSSL_add_all_algorithms.html>

=item * OPENSSL_add_all_algorithms_conf

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Similar to L</OpenSSL_add_all_algorithms> - will ALWAYS load the config file

    Net::SSLeay::OPENSSL_add_all_algorithms_conf();
    #
    # returns: no return value

=item * OPENSSL_add_all_algorithms_noconf

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Similar to L</OpenSSL_add_all_algorithms> - will NEVER load the config file

    Net::SSLeay::OPENSSL_add_all_algorithms_noconf();
    #
    # returns: no return value

=back

=head3 Low level API: ERR_* and SSL_alert_* related functions

B<NOTE:> Please note that SSL_alert_* function have "SSL_" part stripped from their names.

=over

=item * ERR_clear_error

Clear the error queue.

    Net::SSLeay::ERR_clear_error();
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ERR_clear_error.html>

=item * ERR_error_string

Generates a human-readable string representing the error code $error.

    my $rv = Net::SSLeay::ERR_error_string($error);
    # $error - (unsigned integer) error code
    #
    # returns: string

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ERR_error_string.html>

=item * ERR_get_error

Returns the earliest error code from the thread's error queue and removes the entry.
This function can be called repeatedly until there are no more error codes to return.

    my $rv = Net::SSLeay::ERR_get_error();
    #
    # returns: (unsigned integer) error code

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ERR_get_error.html>

=item * ERR_peek_error

Returns the earliest error code from the thread's error queue without modifying it.

    my $rv = Net::SSLeay::ERR_peek_error();
    #
    # returns: (unsigned integer) error code

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ERR_get_error.html>

=item * ERR_put_error

Adds an error code to the thread's error queue. It signals that the error of $reason
code reason occurred in function $func of library $lib, in line number $line of $file.

    Net::SSLeay::ERR_put_error($lib, $func, $reason, $file, $line);
    # $lib - (integer) library id (check openssl/err.h for constants e.g. ERR_LIB_SSL)
    # $func - (integer) function id (check openssl/ssl.h for constants e.g. SSL_F_SSL23_READ)
    # $reason - (integer) reason id (check openssl/ssl.h for constants e.g. SSL_R_SSL_HANDSHAKE_FAILURE)
    # $file - (string) file name
    # $line - (integer) line number in $file
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ERR_put_error.html>
and L<https://www.openssl.org/docs/manmaster/man3/err.html>

=item * alert_desc_string

Returns a two letter string as a short form describing the reason of the alert specified by value.

    my $rv = Net::SSLeay::alert_desc_string($value);
    # $value - (integer) alert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants)
    #
    # returns: description string (2 letters)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_alert_type_string.html>

=item * alert_desc_string_long

Returns a string describing the reason of the alert specified by value.

    my $rv = Net::SSLeay::alert_desc_string_long($value);
    # $value - (integer) alert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants)
    #
    # returns: description string

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_alert_type_string.html>

=item * alert_type_string

Returns a one letter string indicating the type of the alert specified by value.

    my $rv = Net::SSLeay::alert_type_string($value);
    # $value - (integer) alert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants)
    #
    # returns: string (1 letter)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_alert_type_string.html>

=item * alert_type_string_long

Returns a string indicating the type of the alert specified by value.

    my $rv = Net::SSLeay::alert_type_string_long($value);
    # $value - (integer) alert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants)
    #
    # returns: string

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_alert_type_string.html>

=back

=head3 Low level API: SSL_METHOD_* related functions

=over

=item * SSLv23_method, SSLv23_server_method and SSLv23_client_method

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before.

Returns SSL_METHOD structure corresponding to general-purpose version-flexible TLS method, the return value can be later used as a param of L</CTX_new_with_method>.

B<NOTE:> Consider using TLS_method, TLS_server_method or TLS_client_method with new code.

    my $rv = Net::SSLeay::SSLv2_method();
    #
    # returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)

=item * SSLv2_method

Returns SSL_METHOD structure corresponding to SSLv2 method, the return value can be later used as a param of L</CTX_new_with_method>. Only available where supported by the underlying openssl.

    my $rv = Net::SSLeay::SSLv2_method();
    #
    # returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)

=item * SSLv3_method

Returns SSL_METHOD structure corresponding to SSLv3 method, the return value can be later used as a param of L</CTX_new_with_method>.

    my $rv = Net::SSLeay::SSLv3_method();
    #
    # returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_new.html>

=item * TLSv1_method, TLSv1_server_method and TLSv1_client_method

B<COMPATIBILITY:> Requires OpenSSL or LibreSSL built with support for TLSv1. Server and client methods not available in Net-SSLeay-1.82 and before.

Returns SSL_METHOD structure corresponding to TLSv1 method, the return value can be later used as a param of L</CTX_new_with_method>.

    my $rv = Net::SSLeay::TLSv1_method();
    #
    # returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_new.html>

=item * TLSv1_1_method, TLSv1_1_server_method and TLSv1_1_client_method

B<COMPATIBILITY:> Requires OpenSSL >= 1.0.1 or LibreSSL built with support for TLSv1.1. Server and client methods not available in Net-SSLeay-1.82 and before.

Returns SSL_METHOD structure corresponding to TLSv1_1 method, the return value can be later used as a param of L</CTX_new_with_method>.

    my $rv = Net::SSLeay::TLSv1_1_method();
    #
    # returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_new.html>

=item * TLSv1_2_method, TLSv1_2_server_method and TLSv1_2_client_method

B<COMPATIBILITY:> Requires OpenSSL >= 1.0.1 or LibreSSL built with support for TLSv1.2. Server and client methods not available in Net-SSLeay-1.82 and before.

Returns SSL_METHOD structure corresponding to TLSv1_2 method, the return value can be later used as a param of L</CTX_new_with_method>.

    my $rv = Net::SSLeay::TLSv1_2_method();
    #
    # returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_new.html>

=item * TLS_method, TLS_server_method and TLS_client_method

B<COMPATIBILITY:> Not available in Net-SSLeay-1.82 and before.

Returns SSL_METHOD structure corresponding to general-purpose version-flexible TLS method, the return value can be later used as a param of L</CTX_new_with_method>. Only available where supported by the underlying openssl.

    my $rv = Net::SSLeay::TLS_method();
    #
    # returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_new.html>

=back

=head3 Low level API: ENGINE_* related functions

=over

=item * ENGINE_load_builtin_engines

B<COMPATIBILITY:> Requires an OpenSSL build with dynamic engine loading support.

Load all bundled ENGINEs into memory and make them visible.

    Net::SSLeay::ENGINE_load_builtin_engines();
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ENGINE_by_id.html>

=item * ENGINE_register_all_complete

B<COMPATIBILITY:> Requires an OpenSSL build with dynamic engine loading support.

Register all loaded ENGINEs for every algorithm they collectively implement.

    Net::SSLeay::ENGINE_register_all_complete();
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ENGINE_by_id.html>

=item * ENGINE_set_default

B<COMPATIBILITY:> Requires an OpenSSL build with dynamic engine loading support.

Set default engine to $e + set its flags to $flags.

    my $rv = Net::SSLeay::ENGINE_set_default($e, $flags);
    # $e - value corresponding to openssl's ENGINE structure
    # $flags - (integer) engine flags
    #          flags value can be made by bitwise "OR"ing:
    #          0x0001 - ENGINE_METHOD_RSA
    #          0x0002 - ENGINE_METHOD_DSA
    #          0x0004 - ENGINE_METHOD_DH
    #          0x0008 - ENGINE_METHOD_RAND
    #          0x0010 - ENGINE_METHOD_ECDH
    #          0x0020 - ENGINE_METHOD_ECDSA
    #          0x0040 - ENGINE_METHOD_CIPHERS
    #          0x0080 - ENGINE_METHOD_DIGESTS
    #          0x0100 - ENGINE_METHOD_STORE
    #          0x0200 - ENGINE_METHOD_PKEY_METHS
    #          0x0400 - ENGINE_METHOD_PKEY_ASN1_METHS
    #          Obvious all-or-nothing cases:
    #          0xFFFF - ENGINE_METHOD_ALL
    #          0x0000 - ENGINE_METHOD_NONE
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ENGINE_by_id.html>

=item * ENGINE_by_id

Get ENGINE by its identification $id.

B<COMPATIBILITY:> Requires an OpenSSL build with dynamic engine loading support.

    my $rv = Net::SSLeay::ENGINE_by_id($id);
    # $id - (string) engine identification e.g. "dynamic"
    #
    # returns: value corresponding to openssl's ENGINE structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/ENGINE_by_id.html>

=back

=head3 Low level API: EVP_PKEY_* related functions

=over

=item * EVP_PKEY_copy_parameters

Copies the parameters from key $from to key $to.

    my $rv = Net::SSLeay::EVP_PKEY_copy_parameters($to, $from);
    # $to - value corresponding to openssl's EVP_PKEY structure
    # $from - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_cmp.html>

=item * EVP_PKEY_new

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Creates a new EVP_PKEY structure.

    my $rv = Net::SSLeay::EVP_PKEY_new();
    #
    # returns: value corresponding to openssl's EVP_PKEY structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_new.html>

=item * EVP_PKEY_free

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Free an allocated EVP_PKEY structure.

    Net::SSLeay::EVP_PKEY_free($pkey);
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_new.html>

=item * EVP_PKEY_assign_RSA

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Set the key referenced by $pkey to $key

B<NOTE:> No reference counter will be increased, i.e. $key will be freed if
$pkey is freed.

    my $rv = Net::SSLeay::EVP_PKEY_assign_RSA($pkey, $key);
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    # $key - value corresponding to openssl's RSA structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_assign_RSA.html>

=item * EVP_PKEY_assign_EC_KEY

B<COMPATIBILITY:> not available in Net-SSLeay-1.74 and before

Set the key referenced by $pkey to $key

B<NOTE:> No reference counter will be increased, i.e. $key will be freed if
$pkey is freed.

    my $rv = Net::SSLeay::EVP_PKEY_assign_EC_KEY($pkey, $key);
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    # $key - value corresponding to openssl's EC_KEY structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_assign_EC_KEY.html>

=item * EVP_PKEY_bits

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns the size of the key $pkey in bits.

    my $rv = Net::SSLeay::EVP_PKEY_bits($pkey);
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: size in bits

=item * EVP_PKEY_security_bits

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before

Returns the size of the key $pkey in bits.

    my $rv = Net::SSLeay::EVP_PKEY_security_bits($pkey);
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: number of bits

=item * EVP_PKEY_size

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns the maximum size of a signature in bytes. The actual signature may be smaller.

    my $rv = Net::SSLeay::EVP_PKEY_size($pkey);
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: the maximum size in bytes

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_size.html>

=item * EVP_PKEY_id

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before; requires at least OpenSSL 1.0.0

Returns $pkey type (integer value of corresponding NID).

    my $rv = Net::SSLeay::EVP_PKEY_id($pkey);
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: (integer) key type

Example:

    my $pubkey = Net::SSLeay::X509_get_pubkey($x509);
    my $type = Net::SSLeay::EVP_PKEY_id($pubkey);
    print Net::SSLeay::OBJ_nid2sn($type);             # prints e.g. 'rsaEncryption'

=back

=head3 Low level API: PEM_* related functions

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/pem.html>

=over

=item * PEM_read_bio_X509

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Loads PEM formatted X509 certificate via given BIO structure.

    my $rv = Net::SSLeay::PEM_read_bio_X509($bio);
    # $bio - value corresponding to openssl's BIO structure
    #
    # returns: value corresponding to openssl's X509 structure (0 on failure)

Example:

    my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
    my $x509 = Net::SSLeay::PEM_read_bio_X509($bio);
    Net::SSLeay::BIO_free($bio);

=item * PEM_read_bio_X509_REQ

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Loads PEM formatted X509_REQ object via given BIO structure.

    my $rv = Net::SSLeay::PEM_read_bio_X509_REQ($bio, $x=NULL, $cb=NULL, $u=NULL);
    # $bio - value corresponding to openssl's BIO structure
    #
    # returns: value corresponding to openssl's X509_REQ structure (0 on failure)

Example:

    my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
    my $x509_req = Net::SSLeay::PEM_read_bio_X509_REQ($bio);
    Net::SSLeay::BIO_free($bio);

=item * PEM_read_bio_DHparams

Reads DH structure from BIO.

    my $rv = Net::SSLeay::PEM_read_bio_DHparams($bio);
    # $bio - value corresponding to openssl's BIO structure
    #
    # returns: value corresponding to openssl's DH structure (0 on failure)

=item * PEM_read_bio_X509_CRL

Reads X509_CRL structure from BIO.

    my $rv = Net::SSLeay::PEM_read_bio_X509_CRL($bio);
    # $bio - value corresponding to openssl's BIO structure
    #
    # returns: value corresponding to openssl's X509_CRL structure (0 on failure)

=item * PEM_read_bio_PrivateKey

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Loads PEM formatted private key via given BIO structure.

    my $rv = Net::SSLeay::PEM_read_bio_PrivateKey($bio, $cb, $data);
    # $bio - value corresponding to openssl's BIO structure
    # $cb - reference to perl callback function
    # $data - data that will be passed to callback function (see examples below)
    #
    # returns: value corresponding to openssl's EVP_PKEY structure (0 on failure)

Example:

    my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
    my $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio); # ask for password if needed
    Net::SSLeay::BIO_free($bio);

To use password you have the following options:

    $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, \&callback_func); # use callback func for getting password
    $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, \&callback_func, $data); # use callback_func + pass $data to callback_func
    $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, undef, "secret"); # use password "secret"
    $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, undef, "");       # use empty password

Callback function signature:

    sub callback_func {
        my ($max_passwd_size, $rwflag, $data) = @_;
        # $max_passwd_size - maximum size of returned password (longer values will be discarded)
        # $rwflag - indicates whether we are loading (0) or storing (1) - for PEM_read_bio_PrivateKey always 0
        # $data - the data passed to PEM_read_bio_PrivateKey as 3rd parameter

        return "secret";
    }

=item * PEM_X509_INFO_read_bio

Reads a BIO containing a PEM formatted file into a STACK_OF(X509_INFO) structure.

    my $rv = Net::SSLeay::PEM_X509_INFO_read_bio($bio);
    # $bio - value corresponding to openssl's BIO structure
    #
    # returns: value corresponding to openssl's STACK_OF(X509_INFO) structure.

Example:

    my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
    my $sk_x509_info = Net::SSLeay::PEM_X509_INFO_read_bio($bio);
    Net::SSLeay::BIO_free($bio);

=item * PEM_get_string_X509

B<NOTE:> Does not exactly correspond to any low level API function

Converts/exports X509 certificate to string (PEM format).

    Net::SSLeay::PEM_get_string_X509($x509);
    # $x509 - value corresponding to openssl's X509 structure
    #
    # returns: string with $x509 in PEM format

=item * PEM_get_string_PrivateKey

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before. Requires legacy provider with OpenSSL 3.0 and later if the default value of C<$enc_alg> (C<DES_CBC>) is used.

Converts public key $pk into PEM formatted string (optionally protected with password).

    my $rv = Net::SSLeay::PEM_get_string_PrivateKey($pk, $passwd, $enc_alg);
    # $pk - value corresponding to openssl's EVP_PKEY structure
    # $passwd - [optional] (string) password to use for key encryption
    # $enc_alg - [optional] algorithm to use for key encryption (default: DES_CBC) - value corresponding to openssl's EVP_CIPHER structure
    #
    # returns: PEM formatted string

Examples:

    $pem_privkey = Net::SSLeay::PEM_get_string_PrivateKey($pk);
    $pem_privkey = Net::SSLeay::PEM_get_string_PrivateKey($pk, "secret");
    $pem_privkey = Net::SSLeay::PEM_get_string_PrivateKey($pk, "secret", Net::SSLeay::EVP_get_cipherbyname("DES-EDE3-CBC"));

=item * PEM_get_string_X509_CRL

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Converts X509_CRL object $x509_crl into PEM formatted string.

    Net::SSLeay::PEM_get_string_X509_CRL($x509_crl);
    # $x509_crl - value corresponding to openssl's X509_CRL structure
    #
    # returns: no return value

=item * PEM_get_string_X509_REQ

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Converts X509_REQ object $x509_crl into PEM formatted string.

    Net::SSLeay::PEM_get_string_X509_REQ($x509_req);
    # $x509_req - value corresponding to openssl's X509_REQ structure
    #
    # returns: no return value

=back

=head3 Low level API: d2i_* (DER format) related functions

=over

=item * d2i_X509_bio

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Loads DER formatted X509 certificate via given BIO structure.

    my $rv = Net::SSLeay::d2i_X509_bio($bp);
    # $bp - value corresponding to openssl's BIO structure
    #
    # returns: value corresponding to openssl's X509 structure (0 on failure)

Example:

    my $bio = Net::SSLeay::BIO_new_file($filename, 'rb');
    my $x509 = Net::SSLeay::d2i_X509_bio($bio);
    Net::SSLeay::BIO_free($bio);

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/d2i_X509.html>

=item * d2i_X509_CRL_bio

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Loads DER formatted X509_CRL object via given BIO structure.

    my $rv = Net::SSLeay::d2i_X509_CRL_bio($bp);
    # $bp - value corresponding to openssl's BIO structure
    #
    # returns: value corresponding to openssl's X509_CRL structure (0 on failure)

Example:

    my $bio = Net::SSLeay::BIO_new_file($filename, 'rb');
    my $x509_crl = Net::SSLeay::d2i_X509_CRL_bio($bio);
    Net::SSLeay::BIO_free($bio);

=item * d2i_X509_REQ_bio

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Loads DER formatted X509_REQ object via given BIO structure.

    my $rv = Net::SSLeay::d2i_X509_REQ_bio($bp);
    # $bp - value corresponding to openssl's BIO structure
    #
    # returns: value corresponding to openssl's X509_REQ structure (0 on failure)

Example:

    my $bio = Net::SSLeay::BIO_new_file($filename, 'rb');
    my $x509_req = Net::SSLeay::d2i_X509_REQ_bio($bio);
    Net::SSLeay::BIO_free($bio);

=back

=head3 Low level API: PKCS12 related functions

=over

=item * P_PKCS12_load_file

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Loads X509 certificate + private key + certificates of CA chain (if present in PKCS12 file).

    my ($privkey, $cert, @cachain) = Net::SSLeay::P_PKCS12_load_file($filename, $load_chain, $password);
    # $filename - name of PKCS12 file
    # $load_chain - [optional] whether load (1) or not(0) CA chain (default: 0)
    # $password - [optional] password for private key
    #
    # returns: triplet ($privkey, $cert, @cachain)
    #          $privkey - value corresponding to openssl's EVP_PKEY structure
    #          $cert - value corresponding to openssl's X509 structure
    #          @cachain - array of values corresponding to openssl's X509 structure (empty if no CA chain in PKCS12)

B<IMPORTANT NOTE:> after you do the job you need to call X509_free() on $privkey + all members
of @cachain and EVP_PKEY_free() on $privkey.

Examples:

    my ($privkey, $cert) = Net::SSLeay::P_PKCS12_load_file($filename);
    # or
    my ($privkey, $cert) = Net::SSLeay::P_PKCS12_load_file($filename, 0, $password);
    # or
    my ($privkey, $cert, @cachain) = Net::SSLeay::P_PKCS12_load_file($filename, 1);
    # or
    my ($privkey, $cert, @cachain) = Net::SSLeay::P_PKCS12_load_file($filename, 1, $password);

    # BEWARE: THIS IS WRONG - MEMORY LEAKS! (you cannot free @cachain items)
    my ($privkey, $cert) = Net::SSLeay::P_PKCS12_load_file($filename, 1, $password);

B<NOTE> Net::SSLeay 1.92_01 and earlier: With some combinations of
Windows, perl, compiler and compiler options, you may see a runtime
error "no OPENSSL_Applink", when calling
Net::SSLeay::P_PKCS12_load_file. See README.Win32 for more details.

=back

=head3 Low level API: SESSION_* related functions

=over

=item * d2i_SSL_SESSION

B<COMPATIBILITY:> does not work in Net-SSLeay-1.85 and before

Transforms the binary ASN1 representation string of an SSL/TLS session into an
SSL_SESSION object.

    my $ses = Net::SSLeay::d2i_SSL_SESSION($data);
    # $data - the session as ASN1 representation string
    #
    # returns: $ses - the new SSL_SESSION

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/i2d_SSL_SESSION.html>

=item * i2d_SSL_SESSION

B<COMPATIBILITY:> does not work in Net-SSLeay-1.85 and before

Transforms the SSL_SESSION object in into the ASN1 representation and returns
it as string.

    my $data = Net::SSLeay::i2d_SSL_SESSION($ses);
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: $data - session as string

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/d2i_SSL_SESSION.html>

=item * SESSION_new

Creates a new SSL_SESSION structure.

    my $rv = Net::SSLeay::SESSION_new();
    #
    # returns: value corresponding to openssl's SSL_SESSION structure (0 on failure)

=item * SESSION_free

Free an allocated SSL_SESSION structure.

    Net::SSLeay::SESSION_free($ses);
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_free.html>

=item * SESSION_up_ref

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0-pre4 or LibreSSL 2.7.0

Increases the reference counter on a SSL_SESSION structure.

    Net::SSLeay::SESSION_up_ref($ses);
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: 1 on success else 0

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_up_ref.html>

=item * SESSION_dup

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Duplicates a SSL_SESSION structure.

    Net::SSLeay::SESSION_dup($ses);
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: the duplicated session

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_dup.html>

=item * SESSION_is_resumable

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Determine whether an SSL_SESSION object can be used for resumption.

    Net::SSLeay::SESSION_is_resumable($ses);
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: (integer) 1 if it can or 0 if not

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_is_resumable.html>

=item * SESSION_cmp

Compare two SSL_SESSION structures.

    my $rv = Net::SSLeay::SESSION_cmp($sesa, $sesb);
    # $sesa - value corresponding to openssl's SSL_SESSION structure
    # $sesb - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: 0 if the two structures are the same

B<NOTE:> Not available in openssl 1.0 or later

=item * SESSION_get_app_data

Can be used to get application defined value/data.

    my $rv = Net::SSLeay::SESSION_get_app_data($ses);
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: string/buffer/pointer ???

=item * SESSION_set_app_data

Can be used to set some application defined value/data.

    my $rv = Net::SSLeay::SESSION_set_app_data($s, $a);
    # $s - value corresponding to openssl's SSL_SESSION structure
    # $a - (string/buffer/pointer ???) data
    #
    # returns: ???

=item * SESSION_get_ex_data

Is used to retrieve the information for $idx from session $ses.

    my $rv = Net::SSLeay::SESSION_get_ex_data($ses, $idx);
    # $ses - value corresponding to openssl's SSL_SESSION structure
    # $idx - (integer) index for application specific data
    #
    # returns: pointer to ???

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_get_ex_new_index.html>

=item * SESSION_set_ex_data

Is used to store application data at arg for idx into the session object.

    my $rv = Net::SSLeay::SESSION_set_ex_data($ss, $idx, $data);
    # $ss - value corresponding to openssl's SSL_SESSION structure
    # $idx - (integer) ???
    # $data - (pointer) ???
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_get_ex_new_index.html>

=item * SESSION_get_ex_new_index

Is used to register a new index for application specific data.

    my $rv = Net::SSLeay::SESSION_get_ex_new_index($argl, $argp, $new_func, $dup_func, $free_func);
    # $argl - (long) ???
    # $argp - (pointer) ???
    # $new_func - function pointer ??? (CRYPTO_EX_new *)
    # $dup_func - function pointer ??? (CRYPTO_EX_dup *)
    # $free_func - function pointer ??? (CRYPTO_EX_free *)
    #
    # returns: (integer) ???

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_get_ex_new_index.html>

=item * SESSION_get_master_key

B<NOTE:> Does not exactly correspond to any low level API function

Returns 'master_key' value from SSL_SESSION structure $s

    Net::SSLeay::SESSION_get_master_key($s);
    # $s - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: master key (binary data)

=item * SESSION_set1_master_key

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

Sets the master key value associated with a SSL_SESSION.

    my $ret = Net::SSLeay::SESSION_set1_master_key($sess, $key);
    # $sess - value corresponding to OpenSSL SSL_SESSION structure
    # $key - PSK key in packed binary format
    #
    # returns: 1 on success, 0 on failure

Example:

    my $key = pack('H*', 'deadbeef');
    my $ret = Net::SSLeay::SESSION_set1_master_key($sess, $key);

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_set1_master_key.html>

=item * SESSION_set_master_key

Sets 'master_key' value for SSL_SESSION structure $s

    Net::SSLeay::SESSION_set_master_key($s, $key);
    # $s - value corresponding to openssl's SSL_SESSION structure
    # $key - master key (binary data)
    #
    # returns: no return value

Not available with OpenSSL 1.1 and later.
Code that previously used SESSION_set_master_key must now set $secret in the session_secret callback set with SSL_set_session_secret_cb.

=item * SESSION_set_cipher

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

Set the ciphersuite associated with an SSL_SESSION.

    my $ret = Net::SSLeay::SESSION_set_cipher($s, $cipher);
    # $s - value corresponding to OpenSSL SSL_SESSION structure
    # $cipher - value corresponding to OpenSSL SSL_CIPHER structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_set_cipher.html>

=item * SESSION_set_protocol_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

Sets the protocol version associated with an SSL_SESSION.

    my $ret = Net::SSLeay::SESSION_set_protocol_version($s, $version);
    # $s - value corresponding to OpenSSL SSL_SESSION structure
    # $version - integer version constant. For example Net::SSLeay::TLS1_3_VERSION()
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_set_protocol_version.html>

=item * SESSION_get0_cipher

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.0 or LibreSSL 3.4.0

Returns the value corresponding to OpenSSL's SSL_CIPHER associated with an SSL_SESSION.

    my $ret = Net::SSLeay::SESSION_get0_cipher($s);
    # $s - value corresponding to OpenSSL SSL_SESSION structure
    #
    # returns: A value corresponding to OpenSSL's SSL_CIPHER structure or undef if SSL_CIPHER can't be determined.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_get0_cipher.html>

=item * SESSION_get_time

Returns the time at which the session s was established.
The time is given in seconds since 1.1.1970.

    my $rv = Net::SSLeay::SESSION_get_time($s);
    # $s - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: timestamp (seconds since 1.1.1970)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_get_time.html>

=item * get_time

Technically the same functionality as L</SESSION_get_time>.

    my $rv = Net::SSLeay::get_time($s);

=item * SESSION_get_timeout

Returns the timeout value set for session $s in seconds.

    my $rv = Net::SSLeay::SESSION_get_timeout($s);
    # $s - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: timeout (in seconds)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_get_time.html>

=item * get_timeout

Technically the same functionality as L</SESSION_get_timeout>.

    my $rv = Net::SSLeay::get_timeout($s);

=item * SESSION_print

B<NOTE:> Does not exactly correspond to any low level API function

Prints session details (e.g. protocol version, cipher, session-id ...) to BIO.

    my $rv = Net::SSLeay::SESSION_print($fp, $ses);
    # $fp - value corresponding to openssl's BIO structure
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: 1 on success, 0 on failure

You have to use necessary BIO functions like this:

    # let us have $ssl corresponding to openssl's SSL structure
    my $ses = Net::SSLeay::get_session($ssl);
    my $bio = Net::SSLeay::BIO_new(&Net::SSLeay::BIO_s_mem);
    Net::SSLeay::SESSION_print($bio, $ses);
    print Net::SSLeay::BIO_read($bio);

=item * SESSION_print_fp

Prints session details (e.g. protocol version, cipher, session-id ...) to file handle.

B<NOTE> With some combinations of Windows, perl, compiler and compiler
options, you may see a runtime error "no OPENSSL_Applink", when
calling Net::SSLeay::SESSION_print_fp. See README.Win32 for more
details.

    my $rv = Net::SSLeay::SESSION_print_fp($fp, $ses);
    # $fp - perl file handle
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: 1 on success, 0 on failure

Example:

    # let us have $ssl corresponding to openssl's SSL structure
    my $ses = Net::SSLeay::get_session($ssl);
    open my $fh, ">", "output.txt";
    Net::SSLeay::SESSION_print_fp($fh,$ses);

Similar functionality without Net::SSLeay::SESSION_print_fp

    my $ses = Net::SSLeay::get_session($ssl);
    my $bio = Net::SSLeay::BIO_new_file('output.txt', 'w');
    Net::SSLeay::SESSION_print($bio, $ses);

=item * SESSION_set_time

Replaces the creation time of the session s with the chosen value $t (seconds since 1.1.1970).

    my $rv = Net::SSLeay::SESSION_set_time($ses, $t);
    # $ses - value corresponding to openssl's SSL_SESSION structure
    # $t - time value
    #
    # returns: 1 on success

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_get_time.html>

=item * set_time

Technically the same functionality as L</SESSION_set_time>.

    my $rv = Net::SSLeay::set_time($ses, $t);

=item * SESSION_set_timeout

Sets the timeout value for session s in seconds to $t.

    my $rv = Net::SSLeay::SESSION_set_timeout($s, $t);
    # $s - value corresponding to openssl's SSL_SESSION structure
    # $t - timeout (in seconds)
    #
    # returns: 1 on success

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_get_time.html>

=item * set_timeout

Technically the same functionality as L</SESSION_set_timeout>.

    my $rv = Net::SSLeay::set_timeout($ses, $t);

=back

=head3 Low level API: SSL_CTX_* related functions

B<NOTE:> Please note that the function described in this chapter have "SSL_" part stripped from their original openssl names.

=over

=item * CTX_add_client_CA

Adds the CA name extracted from $cacert to the list of CAs sent to the client when requesting a client certificate for $ctx.

    my $rv = Net::SSLeay::CTX_add_client_CA($ctx, $cacert);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $cacert - value corresponding to openssl's X509 structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_client_CA_list.html>

=item * CTX_add_extra_chain_cert

Adds the certificate $x509 to the certificate chain presented together with the certificate. Several certificates can be added one after the other.

    my $rv = Net::SSLeay::CTX_add_extra_chain_cert($ctx, $x509);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $x509 - value corresponding to openssl's X509 structure
    #
    # returns: 1 on success, check out the error stack to find out the reason for failure otherwise

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_add_extra_chain_cert.html>

=item * CTX_add_session

Adds the session $ses to the context $ctx.

    my $rv = Net::SSLeay::CTX_add_session($ctx, $ses);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_add_session.html>

=item * CTX_callback_ctrl

??? (more info needed)

    my $rv = Net::SSLeay::CTX_callback_ctrl($ctx, $cmd, $fp);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $cmd - (integer) command id
    # $fp - (function pointer) ???
    #
    # returns: ???

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_ctrl.html>

=item * CTX_check_private_key

Checks the consistency of a private key with the corresponding certificate loaded into $ctx.

    my $rv = Net::SSLeay::CTX_check_private_key($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * CTX_ctrl

Internal handling function for SSL_CTX objects.

B<BEWARE:> openssl doc says: This function should never be called directly!

    my $rv = Net::SSLeay::CTX_ctrl($ctx, $cmd, $larg, $parg);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $cmd - (integer) command id
    # $larg - (integer) long ???
    # $parg - (string/pointer) ???
    #
    # returns: (long) result of given command ???

    # valid $cmd values
    # 1 - SSL_CTRL_NEED_TMP_RSA
    # 2 - SSL_CTRL_SET_TMP_RSA
    # 3 - SSL_CTRL_SET_TMP_DH
    # 4 - SSL_CTRL_SET_TMP_ECDH
    # 5 - SSL_CTRL_SET_TMP_RSA_CB
    # 6 - SSL_CTRL_SET_TMP_DH_CB
    # 7 - SSL_CTRL_SET_TMP_ECDH_CB
    # 8 - SSL_CTRL_GET_SESSION_REUSED
    # 9 - SSL_CTRL_GET_CLIENT_CERT_REQUEST
    # 10 - SSL_CTRL_GET_NUM_RENEGOTIATIONS
    # 11 - SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS
    # 12 - SSL_CTRL_GET_TOTAL_RENEGOTIATIONS
    # 13 - SSL_CTRL_GET_FLAGS
    # 14 - SSL_CTRL_EXTRA_CHAIN_CERT
    # 15 - SSL_CTRL_SET_MSG_CALLBACK
    # 16 - SSL_CTRL_SET_MSG_CALLBACK_ARG
    # 17 - SSL_CTRL_SET_MTU
    # 20 - SSL_CTRL_SESS_NUMBER
    # 21 - SSL_CTRL_SESS_CONNECT
    # 22 - SSL_CTRL_SESS_CONNECT_GOOD
    # 23 - SSL_CTRL_SESS_CONNECT_RENEGOTIATE
    # 24 - SSL_CTRL_SESS_ACCEPT
    # 25 - SSL_CTRL_SESS_ACCEPT_GOOD
    # 26 - SSL_CTRL_SESS_ACCEPT_RENEGOTIATE
    # 27 - SSL_CTRL_SESS_HIT
    # 28 - SSL_CTRL_SESS_CB_HIT
    # 29 - SSL_CTRL_SESS_MISSES
    # 30 - SSL_CTRL_SESS_TIMEOUTS
    # 31 - SSL_CTRL_SESS_CACHE_FULL
    # 32 - SSL_CTRL_OPTIONS
    # 33 - SSL_CTRL_MODE
    # 40 - SSL_CTRL_GET_READ_AHEAD
    # 41 - SSL_CTRL_SET_READ_AHEAD
    # 42 - SSL_CTRL_SET_SESS_CACHE_SIZE
    # 43 - SSL_CTRL_GET_SESS_CACHE_SIZE
    # 44 - SSL_CTRL_SET_SESS_CACHE_MODE
    # 45 - SSL_CTRL_GET_SESS_CACHE_MODE
    # 50 - SSL_CTRL_GET_MAX_CERT_LIST
    # 51 - SSL_CTRL_SET_MAX_CERT_LIST
    # 52 - SSL_CTRL_SET_MAX_SEND_FRAGMENT
    # 53 - SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
    # 54 - SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG
    # 55 - SSL_CTRL_SET_TLSEXT_HOSTNAME
    # 56 - SSL_CTRL_SET_TLSEXT_DEBUG_CB
    # 57 - SSL_CTRL_SET_TLSEXT_DEBUG_ARG
    # 58 - SSL_CTRL_GET_TLSEXT_TICKET_KEYS
    # 59 - SSL_CTRL_SET_TLSEXT_TICKET_KEYS
    # 60 - SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT
    # 61 - SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB
    # 62 - SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG
    # 63 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB
    # 64 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG
    # 65 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE
    # 66 - SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS
    # 67 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS
    # 68 - SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS
    # 69 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS
    # 70 - SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP
    # 71 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP
    # 72 - SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB
    # 73 - DTLS_CTRL_GET_TIMEOUT
    # 74 - DTLS_CTRL_HANDLE_TIMEOUT
    # 75 - DTLS_CTRL_LISTEN
    # 76 - SSL_CTRL_GET_RI_SUPPORT
    # 77 - SSL_CTRL_CLEAR_OPTIONS
    # 78 - SSL_CTRL_CLEAR_MODE

    # 82 - SSL_CTRL_GET_EXTRA_CHAIN_CERTS
    # 83 - SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS

    # 88 - SSL_CTRL_CHAIN
    # 89 - SSL_CTRL_CHAIN_CERT

    # 90 - SSL_CTRL_GET_CURVES
    # 91 - SSL_CTRL_SET_CURVES
    # 92 - SSL_CTRL_SET_CURVES_LIST
    # 93 - SSL_CTRL_GET_SHARED_CURVE
    # 94 - SSL_CTRL_SET_ECDH_AUTO
    # 97 - SSL_CTRL_SET_SIGALGS
    # 98 - SSL_CTRL_SET_SIGALGS_LIST
    # 99 - SSL_CTRL_CERT_FLAGS
    # 100 - SSL_CTRL_CLEAR_CERT_FLAGS
    # 101 - SSL_CTRL_SET_CLIENT_SIGALGS
    # 102 - SSL_CTRL_SET_CLIENT_SIGALGS_LIST
    # 103 - SSL_CTRL_GET_CLIENT_CERT_TYPES
    # 104 - SSL_CTRL_SET_CLIENT_CERT_TYPES
    # 105 - SSL_CTRL_BUILD_CERT_CHAIN
    # 106 - SSL_CTRL_SET_VERIFY_CERT_STORE
    # 107 - SSL_CTRL_SET_CHAIN_CERT_STORE
    # 108 - SSL_CTRL_GET_PEER_SIGNATURE_NID
    # 109 - SSL_CTRL_GET_SERVER_TMP_KEY
    # 110 - SSL_CTRL_GET_RAW_CIPHERLIST
    # 111 - SSL_CTRL_GET_EC_POINT_FORMATS
    # 112 - SSL_CTRL_GET_TLSA_RECORD
    # 113 - SSL_CTRL_SET_TLSA_RECORD
    # 114 - SSL_CTRL_PULL_TLSA_RECORD

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_ctrl.html>

=item * CTX_flush_sessions

Causes a run through the session cache of $ctx to remove sessions expired at time $tm.

    Net::SSLeay::CTX_flush_sessions($ctx, $tm);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $tm - specifies the time which should be used for the expiration test (seconds since 1.1.1970)
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_flush_sessions.html>

=item * CTX_free

Free an allocated SSL_CTX object.

    Net::SSLeay::CTX_free($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_free.html>

=item * CTX_get_app_data

Can be used to get application defined value/data.

    my $rv = Net::SSLeay::CTX_get_app_data($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: string/buffer/pointer ???

=item * CTX_set_app_data

Can be used to set some application defined value/data.

    my $rv = Net::SSLeay::CTX_set_app_data($ctx, $arg);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $arg - (string/buffer/pointer ???) data
    #
    # returns: ???

=item * CTX_get0_param

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0

Returns the current verification parameters.

    my $vpm = Net::SSLeay::CTX_get0_param($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: value corresponding to openssl's X509_VERIFY_PARAM structure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get0_param.html>

=item * CTX_get_cert_store

Returns the current certificate verification storage.

    my $rv = Net::SSLeay::CTX_get_cert_store($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: value corresponding to openssl's X509_STORE structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_cert_store.html>

=item * CTX_get_client_CA_list

Returns the list of client CAs explicitly set for $ctx using L</CTX_set_client_CA_list>.

    my $rv = Net::SSLeay::CTX_get_client_CA_list($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: value corresponding to openssl's X509_NAME_STACK structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_client_CA_list.html>

=item * CTX_get_ex_data

Is used to retrieve the information for index $idx from $ctx.

    my $rv = Net::SSLeay::CTX_get_ex_data($ssl, $idx);
    # $ssl - value corresponding to openssl's SSL_CTX structure
    # $idx - (integer) index for application specific data
    #
    # returns: pointer to ???

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_ex_new_index.html>

=item * CTX_get_ex_new_index

Is used to register a new index for application specific data.

    my $rv = Net::SSLeay::CTX_get_ex_new_index($argl, $argp, $new_func, $dup_func, $free_func);
    # $argl - (long) ???
    # $argp - (pointer) ???
    # $new_func - function pointer ??? (CRYPTO_EX_new *)
    # $dup_func - function pointer ??? (CRYPTO_EX_dup *)
    # $free_func - function pointer ??? (CRYPTO_EX_free *)
    #
    # returns: (integer) ???

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_ex_new_index.html>

=item * CTX_get_mode

Returns the mode set for ctx.

    my $rv = Net::SSLeay::CTX_get_mode($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: mode (bitmask)

    # to decode the return value (bitmask) use:
    # 0x00000001 corresponds to SSL_MODE_ENABLE_PARTIAL_WRITE
    # 0x00000002 corresponds to SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
    # 0x00000004 corresponds to SSL_MODE_AUTO_RETRY
    # 0x00000008 corresponds to SSL_MODE_NO_AUTO_CHAIN
    # 0x00000010 corresponds to SSL_MODE_RELEASE_BUFFERS
    # (note: some of the bits might not be supported by older openssl versions)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_mode.html>

=item * CTX_set_mode

Adds the mode set via bitmask in $mode to $ctx. Options already set before are not cleared.

    my $rv = Net::SSLeay::CTX_set_mode($ctx, $mode);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $mode - mode bitmask
    #
    # returns: the new mode bitmask after adding $mode

For bitmask details see L</CTX_get_mode> (above).

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_mode.html>

=item * CTX_get_options

Returns the options (bitmask) set for $ctx.

    my $rv = Net::SSLeay::CTX_get_options($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: options (bitmask)

B<BEWARE:> The available constants and their values in bitmask depend
on the TLS library. For example, SSL_OP_NO_TLSv1_3 became available
much later than SSL_OP_NO_COMPRESS which is already deprecated by some
libraries. Also, some previously used option values have been recycled
and are now used for newer options. See the list of constants in this
document for options Net::SSLeay currently supports.

You are strongly encouraged to B<check your TLS library> if you need
to use numeric values directly. The following is a sample of historic
values. It may not be correct anymore.

    # to decode the return value (bitmask) use:
    # 0x00000004 corresponds to SSL_OP_LEGACY_SERVER_CONNECT
    # 0x00000800 corresponds to SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
    # 0x00004000 corresponds to SSL_OP_NO_TICKET
    # 0x00010000 corresponds to SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
    # 0x00400000 corresponds to SSL_OP_CIPHER_SERVER_PREFERENCE
    # 0x04000000 corresponds to SSL_OP_NO_TLSv1

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_options.html>

=item * CTX_set_options

Adds the options set via bitmask in $options to ctx. Options already set before are not cleared.

    Net::SSLeay::CTX_set_options($ctx, $options);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $options - options bitmask
    #
    # returns: the new options bitmask after adding $options

For bitmask details see L</CTX_get_options> (above).

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_options.html>

=item * CTX_get_quiet_shutdown

Returns the 'quiet shutdown' setting of $ctx.

    my $rv = Net::SSLeay::CTX_get_quiet_shutdown($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: (integer) the current setting

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_quiet_shutdown.html>

=item * CTX_get_read_ahead

    my $rv = Net::SSLeay::CTX_get_read_ahead($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: (integer) read_ahead value

=item * CTX_get_session_cache_mode

Returns the currently used cache mode (bitmask).

    my $rv = Net::SSLeay::CTX_get_session_cache_mode($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: mode (bitmask)

B<BEWARE:> SESS_CACHE_OFF and other constants are not available in
Net-SSLeay-1.82 and before.  If the constants are not available, the
following values have historically been correct. You are strongly
encouraged to B<check your TLS library> for the current values.

    # to decode the return value (bitmask) use:
    # 0x0000 corresponds to SSL_SESS_CACHE_OFF
    # 0x0001 corresponds to SSL_SESS_CACHE_CLIENT
    # 0x0002 corresponds to SSL_SESS_CACHE_SERVER
    # 0x0080 corresponds to SSL_SESS_CACHE_NO_AUTO_CLEAR
    # 0x0100 corresponds to SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
    # 0x0200 corresponds to SSL_SESS_CACHE_NO_INTERNAL_STORE
    # (note: some of the bits might not be supported by older openssl versions)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_session_cache_mode.html>

=item * CTX_set_session_cache_mode

Enables/disables session caching by setting the operational mode for $ctx to $mode.

    my $rv = Net::SSLeay::CTX_set_session_cache_mode($ctx, $mode);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $mode - mode (bitmask)
    #
    # returns: previously set cache mode

For bitmask details see L</CTX_get_session_cache_mode> (above).

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_session_cache_mode.html>

=item * CTX_get_timeout

Returns the currently set timeout value for $ctx.

    my $rv = Net::SSLeay::CTX_get_timeout($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: timeout in seconds

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_timeout.html>

=item * CTX_get_verify_depth

Returns the verification depth limit currently set in $ctx. If no limit has been explicitly set, -1 is returned and the default value will be used.

    my $rv = Net::SSLeay::CTX_get_verify_depth($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: depth limit currently set in $ctx, -1 if no limit has been explicitly set

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_verify_mode.html>

=item * CTX_get_verify_mode

Returns the verification mode (bitmask) currently set in $ctx.

    my $rv = Net::SSLeay::CTX_get_verify_mode($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: mode (bitmask)

For bitmask details see L</"CTX_set_verify">.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_verify_mode.html>

=item * CTX_set_verify

Sets the verification flags for $ctx to be $mode and specifies the verify_callback function to be used.

    Net::SSLeay::CTX_set_verify($ctx, $mode, $callback);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $mode - mode (bitmask), see OpenSSL manual
    # $callback - [optional] reference to perl callback function
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_verify.html>

=item * CTX_set_post_handshake_auth

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Enable the Post-Handshake Authentication extension to be added to the ClientHello such that post-handshake authentication can be requested by the server.

    Net::SSLeay::CTX_set_posthandshake_auth($ctx, $val);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $val - 0 then the extension is not sent, otherwise it is
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_post_handshake_auth.html>

=item * CTX_load_verify_locations

Specifies the locations for $ctx, at which CA certificates for verification purposes are located. The certificates available via $CAfile and $CApath are trusted.

    my $rv = Net::SSLeay::CTX_load_verify_locations($ctx, $CAfile, $CApath);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $CAfile - (string) file of CA certificates in PEM format, the file can contain several CA certificates (or '')
    # $CApath - (string) directory containing CA certificates in PEM format (or '')
    #
    # returns: 1 on success, 0 on failure (check the error stack to find out the reason)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_load_verify_locations.html>

=item * CTX_need_tmp_RSA

Return the result of C<SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)>

    my $rv = Net::SSLeay::CTX_need_tmp_RSA($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: result of SSL_CTRL_NEED_TMP_RSA command

Not available with OpenSSL 1.1 and later.

=item * CTX_new

The same as L</CTX_v23_new>

    my $rv = Net::SSLeay::CTX_new();
    #
    # returns: value corresponding to openssl's SSL_CTX structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_new.html>

Not available with OpenSSL 1.1 and later.

=item * CTX_v2_new

Creates a new SSL_CTX object - based on SSLv2_method() - as framework to establish TLS/SSL enabled connections.

    my $rv = Net::SSLeay::CTX_v2_new();
    #
    # returns: value corresponding to openssl's SSL_CTX structure (0 on failure)

=item * CTX_v23_new

Creates a new SSL_CTX object - based on SSLv23_method() - as framework to establish TLS/SSL enabled connections.

    my $rv = Net::SSLeay::CTX_v23_new();
    #
    # returns: value corresponding to openssl's SSL_CTX structure (0 on failure)

=item * CTX_v3_new

Creates a new SSL_CTX object - based on SSLv3_method() - as framework to establish TLS/SSL enabled connections.

    my $rv = Net::SSLeay::CTX_v3_new();
    #
    # returns: value corresponding to openssl's SSL_CTX structure (0 on failure)

=item * CTX_tlsv1_new

B<COMPATIBILITY:> Requires OpenSSL or LibreSSL built with support for TLSv1.

Creates a new SSL_CTX object - based on C<TLSv1_method()> - as a framework for establishing connections using TLSv1.

    my $rv = Net::SSLeay::CTX_tlsv1_new();
    #
    # returns: value corresponding to openssl's SSL_CTX structure (0 on failure)

=item * CTX_tlsv1_1_new

B<COMPATIBILITY:> Requires OpenSSL >= 1.0.1 or LibreSSL built with support for TLSv1.1.

Creates a new SSL_CTX object - based on C<TLSv1_1_method()> - as a framework for establishing connections using TLSv1.1.

    my $rv = Net::SSLeay::CTX_tlsv1_1_new();
    #
    # returns: value corresponding to openssl's SSL_CTX structure (0 on failure)

=item * CTX_tlsv1_2_new

B<COMPATIBILITY:> Requires OpenSSL >= 1.0.1 or LibreSSL built with support for TLSv1.2.

Creates a new SSL_CTX object - based on C<TLSv1_2_method()> - as a framework for establishing connections using TLSv1.2.

    my $rv = Net::SSLeay::CTX_tlsv1_2_new();
    #
    # returns: value corresponding to openssl's SSL_CTX structure (0 on failure)

=item * CTX_new_with_method

Creates a new SSL_CTX object based on $meth method

    my $rv = Net::SSLeay::CTX_new_with_method($meth);
    # $meth - value corresponding to openssl's SSL_METHOD structure
    #
    # returns: value corresponding to openssl's SSL_CTX structure (0 on failure)

    # example
    my $ctx = Net::SSLeay::CTX_new_with_method(&Net::SSLeay::TLSv1_method);

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_new.html>

=item * CTX_set_min_proto_version, CTX_set_max_proto_version, set_min_proto_version and set_max_proto_version,

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0-pre2 or LibreSSL 2.6.0

Set the minimum and maximum supported protocol for $ctx or $ssl.

    my $rv = Net::SSLeay::CTX_set_min_proto_version($ctx, $version);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $version - (integer) constant version value or 0 for automatic lowest or highest value
    #
    # returns: 1 on success, 0 on failure

    # example: allow only TLS 1.2 for a SSL_CTX
    my $rv_min = Net::SSLeay::CTX_set_min_proto_version($ctx, Net::SSLeay::TLS1_2_VERSION());
    my $rv_max = Net::SSLeay::CTX_set_max_proto_version($ctx, Net::SSLeay::TLS1_2_VERSION());

    # example: allow only TLS 1.1 for a SSL
    my $rv_min = Net::SSLeay::set_min_proto_version($ssl, Net::SSLeay::TLS1_1_VERSION());
    my $rv_max = Net::SSLeay::set_max_proto_version($ssl, Net::SSLeay::TLS1_1_VERSION());

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_min_proto_version.html>

=item * CTX_get_min_proto_version, CTX_get_max_proto_version, get_min_proto_version and get_max_proto_version,

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0g

Get the minimum and maximum supported protocol for $ctx or $ssl.

    my $version = Net::SSLeay::CTX_get_min_proto_version($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: 0 automatic lowest or highest value, configured value otherwise

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_min_proto_version.html>

=item * CTX_remove_session

Removes the session $ses from the context $ctx.

    my $rv = Net::SSLeay::CTX_remove_session($ctx, $ses);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_add_session.html>

=item * CTX_sess_accept

    my $rv = Net::SSLeay::CTX_sess_accept($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: number of started SSL/TLS handshakes in server mode

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_accept_good

    my $rv = Net::SSLeay::CTX_sess_accept_good($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: number of successfully established SSL/TLS sessions in server mode

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_accept_renegotiate

    my $rv = Net::SSLeay::CTX_sess_accept_renegotiate($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: number of start renegotiations in server mode

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_cache_full

    my $rv = Net::SSLeay::CTX_sess_cache_full($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: number of sessions that were removed because the maximum session cache size was exceeded

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_cb_hits

    my $rv = Net::SSLeay::CTX_sess_cb_hits($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: number of successfully retrieved sessions from the external session cache in server mode

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_connect

    my $rv = Net::SSLeay::CTX_sess_connect($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: number of started SSL/TLS handshakes in client mode

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_connect_good

     my $rv = Net::SSLeay::CTX_sess_connect_good($ctx);
     # $ctx - value corresponding to openssl's SSL_CTX structure
     #
     # returns: number of successfully established SSL/TLS sessions in client mode

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_connect_renegotiate

     my $rv = Net::SSLeay::CTX_sess_connect_renegotiate($ctx);
     # $ctx - value corresponding to openssl's SSL_CTX structure
     #
     # returns: number of start renegotiations in client mode

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_get_cache_size

Returns the currently valid session cache size.

     my $rv = Net::SSLeay::CTX_sess_get_cache_size($ctx);
     # $ctx - value corresponding to openssl's SSL_CTX structure
     #
     # returns: current size

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_set_cache_size.html>

=item * CTX_sess_hits

     my $rv = Net::SSLeay::CTX_sess_hits($ctx);
     # $ctx - value corresponding to openssl's SSL_CTX structure
     #
     # returns: number of successfully reused sessions

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_misses

     my $rv = Net::SSLeay::CTX_sess_misses($ctx);
     # $ctx - value corresponding to openssl's SSL_CTX structure
     #
     # returns: number of sessions proposed by clients that were not found in the internal session cache in server mode

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_number

     my $rv = Net::SSLeay::CTX_sess_number($ctx);
     # $ctx - value corresponding to openssl's SSL_CTX structure
     #
     # returns: current number of sessions in the internal session cache

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_set_cache_size

Sets the size of the internal session cache of context $ctx to $size.

     Net::SSLeay::CTX_sess_set_cache_size($ctx, $size);
     # $ctx - value corresponding to openssl's SSL_CTX structure
     # $size - cache size (0 = unlimited)
     #
     # returns: previously valid size

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_set_cache_size.html>

=item * CTX_sess_timeouts

Returns the number of sessions proposed by clients and either found in the internal or external session cache in
server mode, but that were invalid due to timeout. These sessions are not included in the SSL_CTX_sess_hits count.

    my $rv = Net::SSLeay::CTX_sess_timeouts($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: number of sessions

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_number.html>

=item * CTX_sess_set_new_cb

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before

Sets the callback function, which is automatically called whenever a new session was negotiated.

    Net::SSLeay::CTX_sess_set_new_cb($ctx, $func);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $func - perl reference to callback function
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_set_new_cb.html>

=item * CTX_sess_set_remove_cb

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before

Sets the callback function, which is automatically called whenever a session is removed by the SSL engine.

    Net::SSLeay::CTX_sess_set_remove_cb($ctx, $func);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $func - perl reference to callback function
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_set_remove_cb.html>

=item * CTX_sessions

Returns a pointer to the lhash databases containing the internal session cache for ctx.

    my $rv = Net::SSLeay::CTX_sessions($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: value corresponding to openssl's LHASH structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sessions.html>

=item * CTX_set1_param

B<COMPATIBILITY:> requires at least OpenSSL 1.0.0-beta3

Applies X509 verification parameters $vpm on $ctx

    my $rv = Net::SSLeay::CTX_set1_param($ctx, $vpm);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $vpm - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get0_param.html>

=item * CTX_set_cert_store

Sets/replaces the certificate verification storage of $ctx to/with $store.

    Net::SSLeay::CTX_set_cert_store($ctx, $store);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $store - value corresponding to openssl's X509_STORE structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_cert_store.html>

=item * CTX_set_cert_verify_callback

Sets the verification callback function for $ctx. SSL objects that are created from $ctx
inherit the setting valid at the time when C<Net::SSLeay::new($ctx)> is called.

    Net::SSLeay::CTX_set_cert_verify_callback($ctx, $func, $data);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $func - perl reference to callback function
    # $data - [optional] data that will be passed to callback function when invoked
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_cert_verify_callback.html>

=item * CTX_set_cipher_list

Sets the list of available ciphers for $ctx using the control string $str.
The list of ciphers is inherited by all ssl objects created from $ctx.

    my $rv = Net::SSLeay::CTX_set_cipher_list($s, $str);
    # $s - value corresponding to openssl's SSL_CTX structure
    # $str - (string) cipher list e.g. '3DES:+RSA'
    #
    # returns: 1 if any cipher could be selected and 0 on complete failure

The format of $str is described in L<https://www.openssl.org/docs/manmaster/man1/openssl-ciphers.html>

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_cipher_list.html>

=item * CTX_set_ciphersuites

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Configure the available TLSv1.3 ciphersuites.

    my $rv = Net::SSLeay::CTX_set_ciphersuites($ctx, $str);
    # $ctx  - value corresponding to openssl's SSL_CTX structure
    # $str  - colon (":") separated list of TLSv1.3 ciphersuite names in order of preference
    #
    # returns: (integer) 1 if the requested ciphersuite list was configured, and 0 otherwise

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_ciphersuites.html>

=item * CTX_set_client_CA_list

Sets the list of CAs sent to the client when requesting a client certificate for $ctx.

    Net::SSLeay::CTX_set_client_CA_list($ctx, $list);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $list - value corresponding to openssl's X509_NAME_STACK structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_client_CA_list.html>

=item * CTX_set_default_passwd_cb

Sets the default password callback called when loading/storing a PEM certificate with encryption.

    Net::SSLeay::CTX_set_default_passwd_cb($ctx, $func);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $func - perl reference to callback function
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_default_passwd_cb.html>

=item * CTX_set_default_passwd_cb_userdata

Sets a pointer to userdata which will be provided to the password callback on invocation.

    Net::SSLeay::CTX_set_default_passwd_cb_userdata($ctx, $userdata);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $userdata - data that will be passed to callback function when invoked
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_default_passwd_cb.html>

=item * CTX_set_default_verify_paths

??? (more info needed)

    my $rv = Net::SSLeay::CTX_set_default_verify_paths($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: 1 on success, 0 on failure

=item * CTX_set_ex_data

Is used to store application data at $data for $idx into the $ctx object.

    my $rv = Net::SSLeay::CTX_set_ex_data($ssl, $idx, $data);
    # $ssl - value corresponding to openssl's SSL_CTX structure
    # $idx - (integer) ???
    # $data - (pointer) ???
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_ex_new_index.html>

=item * CTX_set_purpose

    my $rv = Net::SSLeay::CTX_set_purpose($s, $purpose);
    # $s - value corresponding to openssl's SSL_CTX structure
    # $purpose - (integer) purpose identifier
    #
    # returns: 1 on success, 0 on failure

    # available purpose identifier
    # 1 - X509_PURPOSE_SSL_CLIENT
    # 2 - X509_PURPOSE_SSL_SERVER
    # 3 - X509_PURPOSE_NS_SSL_SERVER
    # 4 - X509_PURPOSE_SMIME_SIGN
    # 5 - X509_PURPOSE_SMIME_ENCRYPT
    # 6 - X509_PURPOSE_CRL_SIGN
    # 7 - X509_PURPOSE_ANY
    # 8 - X509_PURPOSE_OCSP_HELPER
    # 9 - X509_PURPOSE_TIMESTAMP_SIGN

    # or use corresponding constants
    $purpose = &Net::SSLeay::X509_PURPOSE_SSL_CLIENT;
    # ...
    $purpose = &Net::SSLeay::X509_PURPOSE_TIMESTAMP_SIGN;

=item * CTX_set_quiet_shutdown

Sets the 'quiet shutdown' flag for $ctx to be mode. SSL objects created from $ctx inherit the mode valid at the time C<Net::SSLeay::new($ctx)> is called.

    Net::SSLeay::CTX_set_quiet_shutdown($ctx, $mode);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $mode - 0 or 1
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_quiet_shutdown.html>

=item * CTX_set_read_ahead

    my $rv = Net::SSLeay::CTX_set_read_ahead($ctx, $val);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $val - read_ahead value to be set
    #
    # returns: the original read_ahead value

=item * CTX_set_session_id_context

Sets the context $sid_ctx of length $sid_ctx_len within which a session can be reused for the $ctx object.

    my $rv = Net::SSLeay::CTX_set_session_id_context($ctx, $sid_ctx, $sid_ctx_len);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $sid_ctx - data buffer
    # $sid_ctx_len - length of data in $sid_ctx
    #
    # returns: 1 on success, 0 on failure (the error is logged to the error stack)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_session_id_context.html>

=item * CTX_set_ssl_version

Sets a new default TLS/SSL method for SSL objects newly created from this $ctx.
SSL objects already created with C<Net::SSLeay::new($ctx)> are not
affected, except when C<Net::SSLeay:clear($ssl)> is being called.

    my $rv = Net::SSLeay::CTX_set_ssl_version($ctx, $meth);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $meth - value corresponding to openssl's SSL_METHOD structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_ssl_version.html>

=item * CTX_set_timeout

Sets the timeout for newly created sessions for $ctx to $t. The timeout value $t must be given in seconds.

    my $rv = Net::SSLeay::CTX_set_timeout($ctx, $t);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $t - timeout in seconds
    #
    # returns: previously set timeout value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_timeout.html>

=item * CTX_set_tmp_dh

Sets DH parameters to be used to be $dh. The key is inherited by all ssl objects created from $ctx.

    my $rv = Net::SSLeay::CTX_set_tmp_dh($ctx, $dh);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $dh - value corresponding to openssl's DH structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_tmp_dh_callback.html>

=item * CTX_set_tmp_dh_callback

Sets the callback function for $ctx to be used when a DH parameters are required to $tmp_dh_callback.

    Net::SSLeay::CTX_set_tmp_dh_callback($ctx, $tmp_dh_callback);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # tmp_dh_callback - (function pointer) ???
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_tmp_dh_callback.html>

=item * CTX_set_tmp_rsa

Sets the temporary/ephemeral RSA key to be used to be $rsa.

    my $rv = Net::SSLeay::CTX_set_tmp_rsa($ctx, $rsa);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $rsa - value corresponding to openssl's RSA structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_set_tmp_rsa_callback.html>

Not available with OpenSSL 1.1 and later.

=item * CTX_set_tmp_rsa_callback

Sets the callback function for ctx to be used when a temporary/ephemeral RSA key is required to $tmp_rsa_callback.

??? (does this function really work?)

    Net::SSLeay::CTX_set_tmp_rsa_callback($ctx, $tmp_rsa_callback);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $tmp_rsa_callback - (function pointer) ???
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_set_tmp_rsa_callback.html>

Not available with OpenSSL 1.1 and later.

=item * CTX_set_trust

    my $rv = Net::SSLeay::CTX_set_trust($s, $trust);
    # $s - value corresponding to openssl's SSL_CTX structure
    # $trust - (integer) trust identifier
    #
    # returns: the original value

    # available trust identifiers
    # 1 - X509_TRUST_COMPAT
    # 2 - X509_TRUST_SSL_CLIENT
    # 3 - X509_TRUST_SSL_SERVER
    # 4 - X509_TRUST_EMAIL
    # 5 - X509_TRUST_OBJECT_SIGN
    # 6 - X509_TRUST_OCSP_SIGN
    # 7 - X509_TRUST_OCSP_REQUEST
    # 8 - X509_TRUST_TSA

    # or use corresponding constants
    $trust = &Net::SSLeay::X509_TRUST_COMPAT;
    # ...
    $trust = &Net::SSLeay::X509_TRUST_TSA;

=item * CTX_set_verify_depth

Sets the maximum depth for the certificate chain verification that shall be allowed for ctx.

    Net::SSLeay::CTX_set_verify_depth($ctx, $depth);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $depth - max. depth
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_verify.html>

=item * CTX_use_PKCS12_file

Adds the certificate and private key from PKCS12 file $p12filename to $ctx.

    my $rv = Net::SSLeay::CTX_use_PKCS12_file($ctx, $p12filename, $password);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $p12filename - (string) filename
    # $password - (string) password to decrypt private key
    #
    # returns: 1 on success, 0 on failure

B<NOTE> Net::SSLeay 1.92_01 and earlier: With some combinations of
Windows, perl, compiler and compiler options, you may see a runtime
error "no OPENSSL_Applink", when calling
Net::SSLeay::CTX_use_PKCS12_file. See README.Win32 for more details.

=item * CTX_use_PrivateKey

Adds the private key $pkey to $ctx.

    my $rv = Net::SSLeay::CTX_use_PrivateKey($ctx, $pkey);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * CTX_use_PrivateKey_file

Adds the first private key found in $file to $ctx.

    my $rv = Net::SSLeay::CTX_use_PrivateKey_file($ctx, $file, $type);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $file - (string) file name
    # $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * CTX_use_RSAPrivateKey

Adds the RSA private key $rsa to $ctx.

    my $rv = Net::SSLeay::CTX_use_RSAPrivateKey($ctx, $rsa);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $rsa - value corresponding to openssl's RSA structure
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * CTX_use_RSAPrivateKey_file

Adds the first RSA private key found in $file to $ctx.

    my $rv = Net::SSLeay::CTX_use_RSAPrivateKey_file($ctx, $file, $type);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $file - (string) file name
    # $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

=item * CTX_use_certificate

Loads the certificate $x into $ctx

    my $rv = Net::SSLeay::CTX_use_certificate($ctx, $x);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * CTX_use_certificate_chain_file

Loads a certificate chain from $file into $ctx. The certificates must be in PEM format and must be sorted
starting with the subject's certificate (actual client or server certificate), followed by intermediate
CA certificates if applicable, and ending at the highest level (root) CA.

    my $rv = Net::SSLeay::CTX_use_certificate_chain_file($ctx, $file);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $file - (string) file name
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * CTX_use_certificate_file

Loads the first certificate stored in $file into $ctx.

    my $rv = Net::SSLeay::CTX_use_certificate_file($ctx, $file, $type);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $file - (string) file name
    # $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * CTX_get_security_level

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL

Returns the security level associated with $ctx.

    my $level = Net::SSLeay::CTX_get_security_level($ctx);
    # $ctx   - value corresponding to openssl's SSL_CTX structure
    #
    # returns: (integer) current security level

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_security_level.html>

=item * CTX_set_security_level

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL

Sets the security level associated with $ctx to $level.

    Net::SSLeay::CTX_set_security_level($ctx, $level);
    # $ssl   - value corresponding to openssl's SSL_CTX structure
    # $level - new security level
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_security_level.html>

=item * CTX_set_num_tickets

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Set number of TLSv1.3 session tickets that will be sent to a client.

    my $rv = Net::SSLeay::CTX_set_num_tickets($ctx, $number_of_tickets);
    # $ctx  - value corresponding to openssl's SSL_CTX structure
    # $number_of_tickets - number of tickets to send
    #
    # returns: 1 on success, 0 on failure

Set to zero if you do not no want to support a session resumption.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_num_tickets.html>

=item * CTX_get_num_tickets

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Get number of TLSv1.3 session tickets that will be sent to a client.

    my $number_of_tickets = Net::SSLeay::CTX_get_num_tickets($ctx);
    # $ctx  - value corresponding to openssl's SSL_CTX structure
    #
    # returns: (integer) number of tickets to send

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_num_tickets.html>

=item * CTX_set_keylog_callback

B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

Set the TLS key logging callback.

    Net::SSLeay::CTX_set_keylog_callback($ctx, $cb);
    # $ctx  - value corresponding to openssl's SSL_CTX structure
    # $cb - reference to a perl callback function
    #
    # returns: no return value

The callback function will be called like this:

    keylog_cb_func($ssl, $line);
    # $ssl - value corresponding to OpenSSL's SSL object associated with the connection
    # $line - a string containing the key material in the format used by NSS for its SSLKEYLOGFILE debugging output

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_keylog_callback.html>

=item * CTX_get_keylog_callback

B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

Retrieve the previously set TLS key logging callback.

    my $cb = Net::SSLeay::CTX_get_keylog_callback($ctx);
    # $ctx  - value corresponding to openssl's SSL_CTX structure
    #
    # returns: a reference to a perl callback function or undef if no callback is set

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_keylog_callback.html>

=item * CTX_set_client_hello_cb

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

Set a callback function called during the early stages of ClientHello processing on the server.
When callback is undef, the existing callback is disabled.

    Net::SSLeay::CTX_set_client_hello_cb($ctx, $f, [$arg]);
    # $ctx  - value corresponding to openssl's SSL_CTX structure
    # $f - sub { my ($ssl, $arg) = @_; ...; return ($ret, $al); }
    # $arg - optional data passed to the callback function when invoked
    #
    # returns: no return value

The callback function will be called like this:

    client_hello_cb_func($ssl, $arg);
    # $ssl - value corresponding to OpenSSL's SSL object associated with the connection
    # $arg - data to callback
    #
    # An alert code must be returned with SSL_CLIENT_HELLO_FAILURE.
    # Return value examples:
    # ok: return Net::SSLeay::CLIENT_HELLO_SUCCESS();
    # suspend: return Net::SSLeay::CLIENT_HELLO_RETRY();
    # error: return (Net::SSLeay::CLIENT_HELLO_FAILURE(), Net::SSLeay::AD_NO_APPLICATION_PROTOCOL());

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_client_hello_cb.html>

=back

=head3 Low level API: SSL_* related functions

B<NOTE:> Please note that the function described in this chapter have "SSL_" part stripped from their original openssl names.

=over

=item * new

Creates a new SSL structure which is needed to hold the data for a TLS/SSL connection.
The new structure inherits the settings of the underlying context $ctx: connection
method (SSLv2/v3/TLSv1), options, verification settings, timeout settings.

    my $rv = Net::SSLeay::new($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: value corresponding to openssl's SSL structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_new.html>

=item * accept

Waits for a TLS/SSL client to initiate the TLS/SSL handshake. The communication
channel must already have been set and assigned to the ssl by setting an underlying BIO.

    my $rv = Net::SSLeay::accept($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 1 = success, 0 = handshake not successful, <0 = fatal error during handshake

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_accept.html>

=item * add_client_CA

Adds the CA name extracted from cacert to the list of CAs sent to the client
when requesting a client certificate for the chosen ssl, overriding the setting
valid for ssl's SSL_CTX object.

    my $rv = Net::SSLeay::add_client_CA($ssl, $x);
    # $ssl - value corresponding to openssl's SSL structure
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_client_CA_list.html>

=item * callback_ctrl

??? (more info needed)

    my $rv = Net::SSLeay::callback_ctrl($ssl, $cmd, $fp);
    # $ssl - value corresponding to openssl's SSL structure
    # $cmd - (integer) command id
    # $fp - (function pointer) ???
    #
    # returns: ???

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_ctrl.html>

=item * check_private_key

Checks the consistency of a private key with the corresponding certificate loaded into $ssl

    my $rv = Net::SSLeay::check_private_key($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * clear

Reset SSL object to allow another connection.

    Net::SSLeay::clear($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_clear.html>

=item * connect

Initiate the TLS/SSL handshake with an TLS/SSL server.

    my $rv = Net::SSLeay::connect($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 1 = success, 0 = handshake not successful, <0 = fatal error during handshake

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_connect.html>

=item * copy_session_id

Copies the session structure fro $from to $to (+ also the private key and certificate associated with $from).

    Net::SSLeay::copy_session_id($to, $from);
    # $to - value corresponding to openssl's SSL structure
    # $from - value corresponding to openssl's SSL structure
    #
    # returns: no return value

=item * ctrl

Internal handling function for SSL objects.

B<BEWARE:> openssl doc says: This function should never be called directly!

    my $rv = Net::SSLeay::ctrl($ssl, $cmd, $larg, $parg);
    # $ssl - value corresponding to openssl's SSL structure
    # $cmd - (integer) command id
    # $larg - (integer) long ???
    # $parg - (string/pointer) ???
    #
    # returns: (long) result of given command ???

For more details about valid $cmd values check L</CTX_ctrl>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_ctrl.html>

=item * do_handshake

Will wait for a SSL/TLS handshake to take place. If the connection is in client
mode, the handshake will be started. The handshake routines may have to be
explicitly set in advance using either SSL_set_connect_state or SSL_set_accept_state(3).

    my $rv = Net::SSLeay::do_handshake($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 1 = success, 0 = handshake not successful, <0 = fatal error during handshake

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_do_handshake.html>

=item * dup

Returns a duplicate of $ssl.

    my $rv = Net::SSLeay::dup($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's SSL structure (0 on failure)

=item * free

Free an allocated SSL structure.

    Net::SSLeay::free($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_free.html>

=item * get0_param

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0

Returns the current verification parameters.

    my $vpm = Net::SSLeay::get0_param($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's X509_VERIFY_PARAM structure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get0_param.html>

=item * get_SSL_CTX

Returns a pointer to the SSL_CTX object, from which $ssl was created with Net::SSLeay::new.

    my $rv = Net::SSLeay::get_SSL_CTX($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's SSL_CTX structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_SSL_CTX.html>

=item * set_SSL_CTX

B<COMPATIBILITY:> requires at least OpenSSL 0.9.8f

Sets the SSL_CTX the corresponds to an SSL session.

    my $the_ssl_ctx = Net::SSLeay::set_SSL_CTX($ssl, $ssl_ctx);
    # $ssl - value corresponding to openssl's SSL structure
    # $ssl_ctx - Change the ssl object to the given ssl_ctx
    #
    # returns - the ssl_ctx

=item * get_app_data

Can be used to get application defined value/data.

    my $rv = Net::SSLeay::get_app_data($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: string/buffer/pointer ???

=item * set_app_data

Can be used to set some application defined value/data.

    my $rv = Net::SSLeay::set_app_data($ssl, $arg);
    # $ssl - value corresponding to openssl's SSL structure
    # $arg - (string/buffer/pointer ???) data
    #
    # returns: ???

=item * get_certificate

Gets X509 certificate from an established SSL connection.

    my $rv = Net::SSLeay::get_certificate($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's X509 structure (0 on failure)

=item * get_cipher

Obtains the name of the currently used cipher.

    my $rv = Net::SSLeay::get_cipher($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (string) cipher name e.g. 'DHE-RSA-AES256-SHA' or '', when no session has been established.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_current_cipher.html>

=item * get_cipher_bits

Obtain the number of secret/algorithm bits used.

    my $rv = Net::SSLeay::get_cipher_bits($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: number of secret bits used by current cipher

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_current_cipher.html>
and L<https://www.openssl.org/docs/manmaster/man3/SSL_CIPHER_get_name.html>

=item * get_ciphers

B<COMPATIBILITY:> not available in Net-SSLeay-1.88 and before

Returns a list of SSL_CIPHER structures available for $ssl sorted by preference

    my @ciphers = Net::SSLeay::get_ciphers($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (list) SSL_CIPHER structures or nothing when $ssl is undefined or no ciphers are available

Example:

    my @ciphers = Net::SSLeay::get_ciphers($ssl);
    foreach my $c (@ciphers) {
        print Net::SSLeay::CIPHER_get_name($c) . "\n";
    }

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_ciphers.html>

=item * get_cipher_list

Returns the name (string) of the SSL_CIPHER listed for $ssl with priority $n.

    my $rv = Net::SSLeay::get_cipher_list($ssl, $n);
    # $ssl - value corresponding to openssl's SSL structure
    # $n - (integer) priority
    #
    # returns: (string) cipher name e.g. 'EDH-DSS-DES-CBC3-SHA' or undef in case of error

Call Net::SSLeay::get_cipher_list with priority starting from 0 to obtain
the sorted list of available ciphers, until undef is returned:

    my $priority = 0;
    while (my $c = Net::SSLeay::get_cipher_list($ssl, $priority)) {
        print "cipher[$priority] = $c\n";
        $priority++;
    }

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_cipher_list.html>

=item * get_client_CA_list

Returns the list of client CAs explicitly set for $ssl using C<Net::SSLeay::set_client_CA_list>
or $ssl's SSL_CTX object with C<Net::SSLeay::CTX_set_client_CA_list>, when in server mode.

In client mode, returns the list of client CAs sent from the server, if any.

    my $rv = Net::SSLeay::get_client_CA_list($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's STACK_OF(X509_NAME) structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_client_CA_list.html>

=item * get_current_cipher

Returns the cipher actually used.

    my $rv = Net::SSLeay::get_current_cipher($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's SSL_CIPHER structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_current_cipher.html>

=item * get_default_timeout

Returns the default timeout value assigned to SSL_SESSION objects negotiated for the protocol valid for $ssl.

    my $rv = Net::SSLeay::get_default_timeout($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (long) timeout in seconds

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_default_timeout.html>

=item * get_error

Returns a result code for a preceding call to C<connect>, C<accept>, C<do_handshake>, C<read>, C<peek> or C<write> on $ssl.

    my $rv = Net::SSLeay::get_error($ssl, $ret);
    # $ssl - value corresponding to openssl's SSL structure
    # $ret - return value of preceding TLS/SSL I/O operation
    #
    # returns: result code, which is one of the following values:
    #  0 - SSL_ERROR_NONE
    #  1 - SSL_ERROR_SSL
    #  2 - SSL_ERROR_WANT_READ
    #  3 - SSL_ERROR_WANT_WRITE
    #  4 - SSL_ERROR_WANT_X509_LOOKUP
    #  5 - SSL_ERROR_SYSCALL
    #  6 - SSL_ERROR_ZERO_RETURN
    #  7 - SSL_ERROR_WANT_CONNECT
    #  8 - SSL_ERROR_WANT_ACCEPT

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_error.html>

=item * get_ex_data

Is used to retrieve the information for $idx from $ssl.

    my $rv = Net::SSLeay::get_ex_data($ssl, $idx);
    # $ssl - value corresponding to openssl's SSL structure
    # $idx - (integer) index for application specific data
    #
    # returns: pointer to ???

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_ex_new_index.html>

=item * set_ex_data

Is used to store application data at $data for $idx into the $ssl object.

    my $rv = Net::SSLeay::set_ex_data($ssl, $idx, $data);
    # $ssl - value corresponding to openssl's SSL structure
    # $idx - (integer) ???
    # $data - (pointer) ???
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_ex_new_index.html>

=item * get_ex_new_index

Is used to register a new index for application specific data.

    my $rv = Net::SSLeay::get_ex_new_index($argl, $argp, $new_func, $dup_func, $free_func);
    # $argl - (long) ???
    # $argp - (pointer) ???
    # $new_func - function pointer ??? (CRYPTO_EX_new *)
    # $dup_func - function pointer ??? (CRYPTO_EX_dup *)
    # $free_func - function pointer ??? (CRYPTO_EX_free *)
    #
    # returns: (integer) ???

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_ex_new_index.html>

=item * get_fd

Returns the file descriptor which is linked to $ssl.

    my $rv = Net::SSLeay::get_fd($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: file descriptor (>=0) or -1 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_fd.html>

=item * get_finished

Obtains the latest 'Finished' message sent to the peer. Return value
is zero if there's been no Finished message yet. Default count is
2*EVP_MAX_MD_SIZE that is long enough for all possible Finish
messages. If you supply a non-default count, the resulting return
value may be longer than returned buf's length.

    my $rv = Net::SSLeay::get_finished($ssl, $buf, $count);
    # $ssl - value corresponding to openssl's SSL structure
    # $buf - buffer where the returned data will be stored
    # $count - [optional] max size of return data - default is 2*EVP_MAX_MD_SIZE
    #
    # returns: length of latest Finished message

=item * get_peer_finished

Obtains the latest 'Finished' message expected from the
peer. Parameters and return value are similar to get_finished().

    my $rv = Net::SSLeay::get_peer_finished($ssl, $buf, $count);
    # $ssl - value corresponding to openssl's SSL structure
    # $buf - buffer where the returned data will be stored
    # $count - [optional] max size of return data - default is 2*EVP_MAX_MD_SIZE
    #
    # returns: length of latest Finished message

=item * get_keyblock_size

Gets the length of the TLS keyblock. Look for 'key_block' in TLS 1.2
and earlier TLS RFCs. Consider using TLS exporter interface defined by
RFC 5705 instead of creating your own keying material exporter.

B<NOTE:> Does not exactly correspond to any low level API function. Intended for EAP-FAST.

    my $rv = Net::SSLeay::get_keyblock_size($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: keyblock size, -1 on error

=item * get_mode

Returns the mode (bitmask) set for $ssl.

    my $rv = Net::SSLeay::get_mode($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: mode (bitmask)

To decode the return value (bitmask) see documentation for L</CTX_get_mode>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_mode.html>

=item * set_mode

Adds the mode set via bitmask in $mode to $ssl. Options already set before are not cleared.

    my $rv = Net::SSLeay::set_mode($ssl, $mode);
    # $ssl - value corresponding to openssl's SSL structure
    # $mode - mode (bitmask)
    #
    # returns: the new mode bitmask after adding $mode

For $mode bitmask details see L</CTX_get_mode>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_mode.html>

=item * get_options

Returns the options (bitmask) set for $ssl.

    my $rv = Net::SSLeay::get_options($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: options (bitmask)

To decode the return value (bitmask) see documentation for L</CTX_get_options>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_options.html>

=item * set_options

Adds the options set via bitmask in $options to $ssl. Options already set before are not cleared!

    Net::SSLeay::set_options($ssl, $options);
    # $ssl - value corresponding to openssl's SSL structure
    # $options - options (bitmask)
    #
    # returns: the new options bitmask after adding $options

For $options bitmask details see L</CTX_get_options>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_options.html>

=item * get_peer_certificate

Get the X509 certificate of the peer.

    my $rv = Net::SSLeay::get_peer_certificate($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's X509 structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_peer_certificate.html>

=item * get_peer_cert_chain

Get the certificate chain of the peer as an array of X509 structures.

    my @chain = Net::SSLeay::get_peer_cert_chain($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: list of X509 structures

Example:

    my @chain = Net::SSLeay::get_peer_cert_chain($ssl);
    foreach my $x509 (@chain) {
        print Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_subject_name($cert)) . "\n";
    }

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_peer_cert_chain.html>

=item * get_quiet_shutdown

Returns the 'quiet shutdown' setting of ssl.

    my $rv = Net::SSLeay::get_quiet_shutdown($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (integer) current 'quiet shutdown' value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_quiet_shutdown.html>

=item * get_rbio

Get 'read' BIO linked to an SSL object $ssl.

    my $rv = Net::SSLeay::get_rbio($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's BIO structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_rbio.html>

=item * get_read_ahead

    my $rv = Net::SSLeay::get_read_ahead($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (integer) read_ahead value

=item * set_read_ahead

    Net::SSLeay::set_read_ahead($ssl, $val);
    # $ssl - value corresponding to openssl's SSL structure
    # $val - read_ahead value to be set
    #
    # returns: the original read_ahead value

=item * get_security_level

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL

Returns the security level associated with $ssl.

    my $level = Net::SSLeay::get_security_level($ssl);
    # $ssl   - value corresponding to openssl's SSL structure
    #
    # returns: (integer) current security level

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_security_level.html>

=item * set_security_level

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL

Sets the security level associated with $ssl to $level.

    Net::SSLeay::set_security_level($ssl, $level);
    # $ssl   - value corresponding to openssl's SSL structure
    # $level - new security level
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_security_level.html>

=item * set_num_tickets

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Set number of TLSv1.3 session tickets that will be sent to a client.

    my $rv = Net::SSLeay::set_num_tickets($ssl, $number_of_tickets);
    # $ssl  - value corresponding to openssl's SSL structure
    # $number_of_tickets - number of tickets to send
    #
    # returns: 1 on success, 0 on failure

Set to zero if you do not no want to support a session resumption.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_num_tickets.html>

=item * get_num_tickets

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Get number of TLSv1.3 session tickets that will be sent to a client.

    my $number_of_tickets = Net::SSLeay::get_num_tickets($ctx);
    # $ctx  - value corresponding to openssl's SSL structure
    #
    # returns: number of tickets to send

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_num_tickets.html>

=item * get_server_random

Returns internal SSLv3 server_random value.

    Net::SSLeay::get_server_random($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: server_random value (binary data)

=item * get_client_random

B<NOTE:> Does not exactly correspond to any low level API function

Returns internal SSLv3 client_random value.

    Net::SSLeay::get_client_random($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: client_random value (binary data)

=item * export_keying_material

Returns keying material based on the string $label and optional
$context. Note that with TLSv1.2 and lower, empty context (empty
string) and undefined context (no value or 'undef') will return
different values.

    my $out = Net::SSLeay::export_keying_material($ssl, $olen, $label, $context);
    # $ssl - value corresponding to openssl's SSL structure
    # $olen - number of bytes to return
    # $label - application specific label
    # $context - [optional] context - default is undef for no context
    #
    # returns: keying material (binary data) or undef on error

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_export_keying_material.html>

=item * get_session

Retrieve TLS/SSL session data used in $ssl. The reference count of the SSL_SESSION is NOT incremented.

    my $rv = Net::SSLeay::get_session($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's SSL_SESSION structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_session.html>

=item * SSL_get0_session

The alias for L</get_session> (note that the name is C<SSL_get0_session> NOT C<get0_session>).

    my $rv = Net::SSLeay::SSL_get0_session();

=item * get1_session

Returns a pointer to the SSL_SESSION actually used in $ssl. The reference count of the SSL_SESSION is incremented by 1.

    my $rv = Net::SSLeay::get1_session($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's SSL_SESSION structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_session.html>

=item * get_shared_ciphers

Returns string with a list (colon ':' separated) of ciphers shared between client and server
within SSL session $ssl.

    my $rv = Net::SSLeay::get_shared_ciphers();
    #
    # returns: string like 'ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:...'

=item * get_shutdown

Returns the shutdown mode of $ssl.

    my $rv = Net::SSLeay::get_shutdown($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: shutdown mode (bitmask) of ssl

    # to decode the return value (bitmask) use:
    # 0 - No shutdown setting, yet
    # 1 - SSL_SENT_SHUTDOWN
    # 2 - SSL_RECEIVED_SHUTDOWN

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_shutdown.html>

=item * get_ssl_method

Returns a function pointer to the TLS/SSL method set in $ssl.

    my $rv = Net::SSLeay::get_ssl_method($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_ssl_version.html>

=item * in_init, in_before, is_init_finished, in_connect_init, in_accept_init

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before.

Retrieve information about the handshake state machine. All functions take $ssl as the only argument and return 0 or 1. These functions are recommended over get_state() and state().

    my $rv = Net::SSLeay::is_init_finished($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: All functions return 1 or 0

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_in_init.html>

=item * get_state

B<COMPATIBILITY:> OpenSSL 1.1.0 and later use different constants which are not made available. Use is_init_finished() and related functions instead.

Returns the SSL connection state.

    my $rv = Net::SSLeay::get_state($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (integer) state value
    #          to decode the returned state check:
    #          SSL_ST_* constants in openssl/ssl.h
    #          SSL2_ST_* constants in openssl/ssl2.h
    #          SSL23_ST_* constants in openssl/ssl23.h
    #          SSL3_ST_* + DTLS1_ST_* constants in openssl/ssl3.h

=item * state

Exactly the same as L</get_state>.

    my $rv = Net::SSLeay::state($ssl);

=item * set_state

Sets the SSL connection state.

    Net::SSLeay::set_state($ssl,Net::SSLeay::SSL_ST_ACCEPT());

Not available with OpenSSL 1.1 and later.

=item * get_verify_depth

Returns the verification depth limit currently set in $ssl.

    my $rv = Net::SSLeay::get_verify_depth($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: current depth or -1 if no limit has been explicitly set

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_verify_mode.html>

=item * set_verify_depth

Sets the maximum depth for the certificate chain verification that shall be allowed for $ssl.

    Net::SSLeay::set_verify_depth($ssl, $depth);
    # $ssl - value corresponding to openssl's SSL structure
    # $depth - (integer) depth
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_verify.html>

=item * get_verify_mode

Returns the verification mode (bitmask) currently set in $ssl.

    my $rv = Net::SSLeay::get_verify_mode($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: mode (bitmask)

To decode the return value (bitmask) see documentation for L</CTX_get_verify_mode>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_verify_mode.html>

=item * set_verify

Sets the verification flags for $ssl to be $mode and specifies the $verify_callback function to be used.

    Net::SSLeay::set_verify($ssl, $mode, $callback);
    # $ssl - value corresponding to openssl's SSL structure
    # $mode - mode (bitmask)
    # $callback - [optional] reference to perl callback function
    #
    # returns: no return value

For $mode bitmask details see L</CTX_get_verify_mode>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_verify.html>

=item * set_post_handshake_auth

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Enable the Post-Handshake Authentication extension to be added to the ClientHello such that post-handshake authentication can be requested by the server.

    Net::SSLeay::set_posthandshake_auth($ssl, $val);
    # $ssl - value corresponding to openssl's SSL structure
    # $val - 0 then the extension is not sent, otherwise it is
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_post_handshake_auth.html>

=item * verify_client_post_handshake

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

verify_client_post_handshake causes a CertificateRequest message to be sent by a server on the given ssl connection.

    my $rv = Net::SSLeay::verify_client_post_handshake($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 1 if the request succeeded, and 0 if the request failed. The error stack can be examined to determine the failure reason.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_verify_client_post_handshake.html>

=item * get_verify_result

Returns the result of the verification of the X509 certificate presented by the peer, if any.

    my $rv = Net::SSLeay::get_verify_result($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (integer)
    #      0 - X509_V_OK: ok
    #      2 - X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate
    #      3 - X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL
    #      4 - X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature
    #      5 - X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature
    #      6 - X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key
    #      7 - X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure
    #      8 - X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure
    #      9 - X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid
    #     10 - X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired
    #     11 - X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid
    #     12 - X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired
    #     13 - X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field
    #     14 - X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field
    #     15 - X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field
    #     16 - X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field
    #     17 - X509_V_ERR_OUT_OF_MEM: out of memory
    #     18 - X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate
    #     19 - X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain
    #     20 - X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate
    #     21 - X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate
    #     22 - X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long
    #     23 - X509_V_ERR_CERT_REVOKED: certificate revoked
    #     24 - X509_V_ERR_INVALID_CA: invalid CA certificate
    #     25 - X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded
    #     26 - X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose
    #     27 - X509_V_ERR_CERT_UNTRUSTED: certificate not trusted
    #     28 - X509_V_ERR_CERT_REJECTED: certificate rejected
    #     29 - X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch
    #     30 - X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch
    #     31 - X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch
    #     32 - X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing
    #     50 - X509_V_ERR_APPLICATION_VERIFICATION: application verification failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_verify_result.html>

=item * set_verify_result

Override result of peer certificate verification.

    Net::SSLeay::set_verify_result($ssl, $v);
    # $ssl - value corresponding to openssl's SSL structure
    # $v - (integer) result value
    #
    # returns: no return value

For more info about valid return values see L</get_verify_result>

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_verify_result.html>

=item * get_wbio

Get 'write' BIO linked to an SSL object $ssl.

    my $rv = Net::SSLeay::get_wbio($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: value corresponding to openssl's BIO structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_rbio.html>

=item * load_client_CA_file

Load X509 certificates from file (PEM formatted).

    my $rv = Net::SSLeay::load_client_CA_file($file);
    # $file - (string) file name
    #
    # returns: value corresponding to openssl's STACK_OF(X509_NAME) structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_load_client_CA_file.html>

=item * clear_num_renegotiations

Executes SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS command on $ssl.

    my $rv = Net::SSLeay::clear_num_renegotiations($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: command result

=item * need_tmp_RSA

Executes SSL_CTRL_NEED_TMP_RSA command on $ssl.

    my $rv = Net::SSLeay::need_tmp_RSA($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: command result

Not available with OpenSSL 1.1 and later.

=item * num_renegotiations

Executes SSL_CTRL_GET_NUM_RENEGOTIATIONS command on $ssl.

    my $rv = Net::SSLeay::num_renegotiations($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: command result

=item * total_renegotiations

Executes SSL_CTRL_GET_TOTAL_RENEGOTIATIONS command on $ssl.

    my $rv = Net::SSLeay::total_renegotiations($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: command result

=item * peek

Copies $max bytes from the specified $ssl into the returned value.
In contrast to the C<Net::SSLeay::read()> function, the data in the SSL
buffer is unmodified after the SSL_peek() operation.

    Net::SSLeay::peek($ssl, $max);
    # $ssl - value corresponding to openssl's SSL structure
    # $max - [optional] max bytes to peek (integer) - default is 32768
    #
    # in scalar context: data read from the TLS/SSL connection, undef on error
    # in list context:   two-item array consisting of data read (undef on error),
    #                      and return code from SSL_peek().

=item * peek_ex

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Copies $max bytes from the specified $ssl into the returned value.
In contrast to the C<Net::SSLeay::read_ex()> function, the data in the SSL
buffer is unmodified after the SSL_peek_ex() operation.

    my($got, $rv) = Net::SSLeay::peek_ex($ssl, $max);
    # $ssl - value corresponding to openssl's SSL structure
    # $max - [optional] max bytes to peek (integer) - default is 32768
    #
    # returns a list: two-item list consisting of data read (undef on error),
    #                 and return code from SSL_peek_ex().

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_peek_ex.html>

=item * pending

Obtain number of readable bytes buffered in $ssl object.

    my $rv = Net::SSLeay::pending($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: the number of bytes pending

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_pending.html>

=item * has_pending

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL

Returns 1 if $ssl has buffered data (whether processed or unprocessed) and 0 otherwise.

    my $rv = Net::SSLeay::has_pending($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (integer) 1 or 0

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_has_pending.html>

=item * read

Tries to read $max bytes from the specified $ssl.

    my $got = Net::SSLeay::read($ssl, $max);
    my($got, $rv) = Net::SSLeay::read($ssl, $max);
    # $ssl - value corresponding to openssl's SSL structure
    # $max - [optional] max bytes to read (integer) - default is 32768
    #
    # returns:
    # in scalar context: data read from the TLS/SSL connection, undef on error
    # in list context:   two-item array consisting of data read (undef on error),
    #                      and return code from SSL_read().

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_read.html>

=item * read_ex

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Tries to read $max bytes from the specified $ssl.

    my($got, $rv) = Net::SSLeay::read_ex($ssl, $max);
    # $ssl - value corresponding to openssl's SSL structure
    # $max - [optional] max bytes to read (integer) - default is 32768
    #
    # returns a list: two-item list consisting of data read (undef on error),
    #                 and return code from SSL_read_ex().

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_read_ex.html>

=item * renegotiate

Turn on flags for renegotiation so that renegotiation will happen

    my $rv = Net::SSLeay::renegotiate($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 1 on success, 0 on failure

=item * rstate_string

Returns a 2 letter string indicating the current read state of the SSL object $ssl.

    my $rv = Net::SSLeay::rstate_string($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 2-letter string

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_rstate_string.html>

=item * rstate_string_long

Returns a string indicating the current read state of the SSL object ssl.

    my $rv = Net::SSLeay::rstate_string_long($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: string with current state

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_rstate_string.html>

=item * session_reused

Query whether a reused session was negotiated during handshake.

    my $rv = Net::SSLeay::session_reused($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 0 - new session was negotiated; 1 - session was reused.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_session_reused.html>

=item * set1_param

B<COMPATIBILITY:> requires at least OpenSSL 1.0.0-beta3

Applies X509 verification parameters $vpm on $ssl

    my $rv = Net::SSLeay::set1_param($ssl, $vpm);
    # $ssl - value corresponding to openssl's SSL structure
    # $vpm - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: 1 on success, 0 on failure

=item * set_accept_state

Sets $ssl to work in server mode.

    Net::SSLeay::set_accept_state($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_connect_state.html>

=item * set_bio

Connects the BIOs $rbio and $wbio for the read and write operations of the TLS/SSL (encrypted) side of $ssl.

    Net::SSLeay::set_bio($ssl, $rbio, $wbio);
    # $ssl - value corresponding to openssl's SSL structure
    # $rbio - value corresponding to openssl's BIO structure
    # $wbio - value corresponding to openssl's BIO structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_bio.html>

=item * set_cipher_list

Sets the list of ciphers only for ssl.

    my $rv = Net::SSLeay::set_cipher_list($ssl, $str);
    # $ssl - value corresponding to openssl's SSL structure
    # $str - (string) cipher list e.g. '3DES:+RSA'
    #
    # returns: 1 if any cipher could be selected and 0 on complete failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_cipher_list.html>

=item * set_ciphersuites

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Configure the available TLSv1.3 ciphersuites.

    my $rv = Net::SSLeay::set_ciphersuites($ssl, $str);
    # $ssl  - value corresponding to openssl's SSL structure
    # $str  - colon (":") separated list of TLSv1.3 ciphersuite names in order of preference
    #
    # returns: (integer) 1 if the requested ciphersuite list was configured, and 0 otherwise

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_ciphersuites.html>

=item * set_client_CA_list

Sets the list of CAs sent to the client when requesting a client certificate
for the chosen $ssl, overriding the setting valid for $ssl's SSL_CTX object.

    my $rv = Net::SSLeay::set_client_CA_list($ssl, $list);
    # $ssl - value corresponding to openssl's SSL structure
    # $list - value corresponding to openssl's STACK_OF(X509_NAME) structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_client_CA_list.html>

=item * set_connect_state

Sets $ssl to work in client mode.

    Net::SSLeay::set_connect_state($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_connect_state.html>

=item * set_fd

Sets the file descriptor $fd as the input/output facility for the TLS/SSL (encrypted)
side of $ssl, $fd will typically be the socket file descriptor of a network connection.

    my $rv = Net::SSLeay::set_fd($ssl, $fd);
    # $ssl - value corresponding to openssl's SSL structure
    # $fd - (integer) file handle (got via perl's fileno)
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_fd.html>

=item * set_psk_client_callback

Sets the psk client callback.

    Net::SSLeay::set_psk_client_callback($ssl, sub { my $hint = shift; return ($identity, $key) } );
    # $ssl - value corresponding to openssl's SSL structure
    # $hint - PSK identity hint send by the server
    # $identity - PSK identity
    # $key - PSK key, hex string without the leading '0x', e.g. 'deadbeef'
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_psk_client_callback.html>

=item * set_rfd

Sets the file descriptor $fd as the input (read) facility for the TLS/SSL (encrypted) side of $ssl.

    my $rv = Net::SSLeay::set_rfd($ssl, $fd);
    # $ssl - value corresponding to openssl's SSL structure
    # $fd - (integer) file handle (got via perl's fileno)
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_fd.html>

=item * set_wfd

    my $rv = Net::SSLeay::set_wfd($ssl, $fd);
    # $ssl - value corresponding to openssl's SSL structure
    # $fd - (integer) file handle (got via perl's fileno)
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_fd.html>

=item * set_info_callback

Sets the callback function, that can be used to obtain state information for $ssl during connection setup and use.
When callback is undef, the callback setting currently valid for ctx is used.

    Net::SSLeay::set_info_callback($ssl, $cb, [$data]);
    # $ssl - value corresponding to openssl's SSL structure
    # $cb - sub { my ($ssl,$where,$ret,$data) = @_; ... }
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_info_callback.html>

=item * CTX_set_info_callback

Sets the callback function on ctx, that can be used to obtain state information during ssl connection setup and use.
When callback is undef, an existing callback will be disabled.

    Net::SSLeay::CTX_set_info_callback($ssl, $cb, [$data]);
    # $ssl - value corresponding to openssl's SSL structure
    # $cb - sub { my ($ssl,$where,$ret,$data) = @_; ... }
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_info_callback.html>

=item * set_msg_callback

Sets the callback function, that can be used to obtain protocol messages information for $ssl during connection setup and use.
When callback is undef, the callback setting currently valid for ctx is used.
Note that set_msg_callback_arg is not provided as there is no need to explicitly set $arg, this is handled by set_msg_callback.

    Net::SSLeay::set_msg_callback($ssl, $cb, [$arg]);
    # $ssl - value corresponding to openssl's SSL structure
    # $cb - sub { my ($write_p,$version,$content_type,$buf,$len,$ssl,$arg) = @_; ... }
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_msg_callback.html>

=item * CTX_set_msg_callback

Sets the callback function on ctx, that can be used to obtain protocol messages information for ssl connection setup and use.
When callback is undef, the existing callback will be disabled.
Note that CTX_set_msg_callback_arg is not provided as there is no need to explicitly set $arg, this is handled by CTX_set_msg_callback.

    Net::SSLeay::CTX_set_msg_callback($ssl, $cb, [$arg]);
    # $ssl - value corresponding to openssl's SSL structure
    # $cb - sub { my ($write_p,$version,$content_type,$buf,$len,$ssl,$arg) = @_; ... }
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_msg_callback.html>

=item * set_pref_cipher

Sets the list of available ciphers for $ssl using the control string $str.

    my $rv = Net::SSLeay::set_pref_cipher($ssl, $str);
    # $ssl - value corresponding to openssl's SSL structure
    # $str - (string) cipher list e.g. '3DES:+RSA'
    #
    # returns: 1 if any cipher could be selected and 0 on complete failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_cipher_list.html>

=item * CTX_set_psk_client_callback

Sets the psk client callback.

    Net::SSLeay::CTX_set_psk_client_callback($ssl, sub { my $hint = shift; return ($identity, $key) } );
    # $ssl - value corresponding to openssl's SSL structure
    # $hint - PSK identity hint send by the server
    # $identity - PSK identity
    # $key - PSK key, hex string without the leading '0x', e.g. 'deadbeef'
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_psk_client_callback.html>

=item * set_purpose

    my $rv = Net::SSLeay::set_purpose($ssl, $purpose);
    # $ssl - value corresponding to openssl's SSL structure
    # $purpose - (integer) purpose identifier
    #
    # returns: 1 on success, 0 on failure

For more info about available $purpose identifiers see L</CTX_set_purpose>.

=item * set_quiet_shutdown

Sets the 'quiet shutdown' flag for $ssl to be $mode.

    Net::SSLeay::set_quiet_shutdown($ssl, $mode);
    # $ssl - value corresponding to openssl's SSL structure
    # $mode - 0 or 1
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_quiet_shutdown.html>

=item * set_session

Set a TLS/SSL session to be used during TLS/SSL connect.

    my $rv = Net::SSLeay::set_session($to, $ses);
    # $to - value corresponding to openssl's SSL structure
    # $ses - value corresponding to openssl's SSL_SESSION structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_session.html>

=item * set_session_id_context

Sets the context $sid_ctx of length $sid_ctx_len within which a session can be reused for the $ssl object.

    my $rv = Net::SSLeay::set_session_id_context($ssl, $sid_ctx, $sid_ctx_len);
    # $ssl - value corresponding to openssl's SSL structure
    # $sid_ctx - data buffer
    # $sid_ctx_len - length of data in $sid_ctx
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_session_id_context.html>

=item * set_session_secret_cb

Setup pre-shared secret session resumption function.

    Net::SSLeay::set_session_secret_cb($ssl, $func, $data);
    # $ssl - value corresponding to openssl's SSL structure
    # $func - perl reference to callback function
    # $data - [optional] data that will be passed to callback function when invoked
    #
    # returns: no return value

The callback function will be called like:

    callback_function($secret, $ciphers, $pref_cipher, $data);
    # $secret is the current master session key, usually all 0s at the beginning of a session
    # $ciphers is ref to an array of peer cipher names
    # $pref_cipher is a ref to an index into the list of cipher names of
    #  the preferred cipher. Set it if you want to specify a preferred cipher
    # $data is the data passed to set_session_secret_cb

The callback function should return 1 if it likes the suggested cipher (or has selected an alternative
by setting pref_cipher), else it should return 0 (in which case OpenSSL will select its own preferred cipher).

With OpenSSL 1.1 and later, callback_function can change the master key for the session by
altering $secret and returning 1.

=item * CTX_set_tlsext_ticket_getkey_cb

Setup encryption for TLS session tickets (stateless session reuse).

    Net::SSLeay::CTX_set_tlsext_ticket_getkey_cb($ctx, $func, $data);
    # $ctx  - value corresponding to openssl's SSL_CTX structure
    # $func - perl reference to callback function
    # $data - [optional] data that will be passed to callback function when invoked
    #
    # returns: no return value

The callback function will be called like:

    getkey($data,[$key_name]) -> ($key,$current_key_name)
    # $data is the data passed to set_session_secret_cb
    # $key_name is the name of the key OpenSSL has extracted from the session ticket
    # $key is the requested key for ticket encryption + HMAC
    # $current_key_name is the name for the currently valid key

OpenSSL will call the function without a key name if it generates a new ticket.
It then needs the callback to return the encryption+HMAC key and an identifier
(key name) for this key.

When OpenSSL gets a session ticket from the client it extracts the key name and
calls the callback with this name as argument. It then expects the callback to
return the encryption+HMAC key matching the requested key name and and also the
key name which should be used at the moment. If the requested key name and the
returned key name differ it means that this session ticket was created with an
expired key and need to be renewed. In this case OpenSSL will call the callback
again with no key name to create a new session ticket based on the old one.

The key must be at least 32 byte of random data which can be created with
RAND_bytes. Internally the first 16 byte are used as key in AES-128 encryption
while the next 16 byte are used for the SHA-256 HMAC.
The key name are binary data and must be exactly 16 byte long.

Example:

    Net::SSLeay::RAND_bytes(my $oldkey,32);
    Net::SSLeay::RAND_bytes(my $newkey,32);
    my $oldkey_name = pack("a16",'oldsecret');
    my $newkey_name = pack("a16",'newsecret');

    my @keys = (
        [ $newkey_name, $newkey ], # current active key
        [ $oldkey_name, $oldkey ], # already expired
    );

    Net::SSLeay::CTX_set_tlsext_ticket_getkey_cb($server2->_ctx, sub {
        my ($mykeys,$name) = @_;

        # return (current_key, current_key_name) if no name given
        return ($mykeys->[0][1],$mykeys->[0][0]) if ! $name;

        # return (matching_key, current_key_name) if we find a key matching
        # the given name
        for(my $i = 0; $i<@$mykeys; $i++) {
            next if $name ne $mykeys->[$i][0];
            return ($mykeys->[$i][1],$mykeys->[0][0]);
        }

        # no matching key found
        return;
    },\@keys);

This function is based on the OpenSSL function SSL_CTX_set_tlsext_ticket_key_cb
but provides a simpler to use interface. For more information see
L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_tlsext_ticket_key_cb.html>

=item * set_session_ticket_ext_cb

Setup callback for TLS session tickets (stateless session reuse).

    Net::SSLeay::set_session_ticket_ext_cb($ssl, $func, $data);
    # $ssl  - value corresponding to openssl's SSL structure
    # $func - perl reference to callback function
    # $data - [optional] data that will be passed to callback function when invoked
    #
    # returns: no return value

The callback function will be called like:

    getticket($ssl,$ticket,$data) -> $return_value
    # $ssl is a value corresponding to openssl's SSL structure
    # $ticket is a value of received TLS session ticket (can also be empty)
    # $data is the data passed to set_session_ticket_ext_cb
    # $return_value is either 0 (failure) or 1 (success)

This function is based on the OpenSSL function SSL_set_session_ticket_ext_cb.

=item * set_session_ticket_ext

Set TLS session ticket (stateless session reuse).

    Net::SSLeay::set_session_ticket_ext($ssl, $ticket);
    # $ssl    - value corresponding to openssl's SSL structure
    # $ticket - is a value of TLS session ticket which client will send (can also be empty string)
    #
    # returns: no return value

The callback function will be called like:

    getticket($ssl,$ticket,$data) -> $return_value
    # $ssl is a value corresponding to openssl's SSL structure
    # $ticket is a value of received TLS session ticket (can also be empty)
    # $data is the data passed to set_session_ticket_ext_cb
    # $return_value is either 0 (failure) or 1 (success)

This function is based on the OpenSSL function SSL_set_session_ticket_ext_cb.

=item * set_shutdown

Sets the shutdown state of $ssl to $mode.

    Net::SSLeay::set_shutdown($ssl, $mode);
    # $ssl - value corresponding to openssl's SSL structure
    # $mode - (integer) shutdown mode:
    #         0 - No shutdown
    #         1 - SSL_SENT_SHUTDOWN
    #         2 - SSL_RECEIVED_SHUTDOWN
    #         3 - SSL_RECEIVED_SHUTDOWN+SSL_SENT_SHUTDOWN
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_shutdown.html>

=item * set_ssl_method

Sets a new TLS/SSL method for a particular $ssl object.

    my $rv = Net::SSLeay::set_ssl_method($ssl, $method);
    # $ssl - value corresponding to openssl's SSL structure
    # $method - value corresponding to openssl's SSL_METHOD structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_ssl_version.html>

=item * set_tmp_dh

Sets DH parameters to be used to be $dh.

    my $rv = Net::SSLeay::set_tmp_dh($ssl, $dh);
    # $ssl - value corresponding to openssl's SSL structure
    # $dh - value corresponding to openssl's DH structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_tmp_dh_callback.html>

=item * set_tmp_dh_callback

Sets the callback function for $ssl to be used when a DH parameters are required to $dh_cb.

??? (does this function really work?)

    Net::SSLeay::set_tmp_dh_callback($ssl, $dh);
    # $ssl - value corresponding to openssl's SSL structure
    # $dh_cb - pointer to function ???
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_tmp_dh_callback.html>

=item * set_tmp_rsa

Sets the temporary/ephemeral RSA key to be used in $ssl to be $rsa.

    my $rv = Net::SSLeay::set_tmp_rsa($ssl, $rsa);
    # $ssl - value corresponding to openssl's SSL structure
    # $rsa - value corresponding to openssl's RSA structure
    #
    # returns: 1 on success, 0 on failure

Example:

    $rsakey = Net::SSLeay::RSA_generate_key();
    Net::SSLeay::set_tmp_rsa($ssl, $rsakey);
    Net::SSLeay::RSA_free($rsakey);

Check openssl doc L<https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_set_tmp_rsa_callback.html>

=item * set_tmp_rsa_callback

Sets the callback function for $ssl to be used when a temporary/ephemeral RSA key is required to $tmp_rsa_callback.

??? (does this function really work?)

    Net::SSLeay::set_tmp_rsa_callback($ssl, $tmp_rsa_callback);
    # $ssl - value corresponding to openssl's SSL structure
    # $tmp_rsa_callback - (function pointer) ???
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_set_tmp_rsa_callback.html>

=item * set_trust

    my $rv = Net::SSLeay::set_trust($ssl, $trust);
    # $ssl - value corresponding to openssl's SSL structure
    # $trust - (integer) trust identifier
    #
    # returns: the original value

For more details about $trust values see L</CTX_set_trust>.

=item * shutdown

Shuts down an active TLS/SSL connection. It sends the 'close notify' shutdown alert to the peer.

    my $rv = Net::SSLeay::shutdown($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 1 - shutdown was successfully completed
    #          0 - shutdown is not yet finished,
    #         -1 - shutdown was not successful

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_shutdown.html>

=item * state_string

Returns a 6 letter string indicating the current state of the SSL object $ssl.

    my $rv = Net::SSLeay::state_string($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: 6-letter string

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_state_string.html>

=item * state_string_long

Returns a string indicating the current state of the SSL object $ssl.

    my $rv = Net::SSLeay::state_string_long($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: state strings

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_state_string.html>

=item * set_default_passwd_cb

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0f. Not needed with LibreSSL.

Sets the default password callback called when loading/storing a PEM certificate with encryption for $ssl.

    Net::SSLeay::set_default_passwd_cb($ssl, $func);
    # $ssl - value corresponding to openssl's SSL structure
    # $func - perl reference to callback function
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_default_passwd_cb.html>

=item * set_default_passwd_cb_userdata

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0f. Not needed with LibreSSL.

Sets a pointer to userdata which will be provided to the password callback of $ssl on invocation.

    Net::SSLeay::set_default_passwd_cb_userdata($ssl, $userdata);
    # $ssl - value corresponding to openssl's SSL structure
    # $userdata - data that will be passed to callback function when invoked
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_default_passwd_cb.html>

=item * use_PrivateKey

Adds $pkey as private key to $ssl.

    my $rv = Net::SSLeay::use_PrivateKey($ssl, $pkey);
    # $ssl - value corresponding to openssl's SSL structure
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * use_PrivateKey_ASN1

Adds the private key of type $pk stored in $data to $ssl.

    my $rv = Net::SSLeay::use_PrivateKey_ASN1($pk, $ssl, $d, $len);
    # $pk - (integer) key type, NID of corresponding algorithm
    # $ssl - value corresponding to openssl's SSL structure
    # $data - key data (binary)
    # $len - length of $data
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * use_PrivateKey_file

Adds the first private key found in $file to $ssl.

    my $rv = Net::SSLeay::use_PrivateKey_file($ssl, $file, $type);
    # $ssl - value corresponding to openssl's SSL structure
    # $file - (string) file name
    # $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * use_RSAPrivateKey

Adds $rsa as RSA private key to $ssl.

    my $rv = Net::SSLeay::use_RSAPrivateKey($ssl, $rsa);
    # $ssl - value corresponding to openssl's SSL structure
    # $rsa - value corresponding to openssl's RSA structure
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * use_RSAPrivateKey_ASN1

Adds RSA private key stored in $data to $ssl.

    my $rv = Net::SSLeay::use_RSAPrivateKey_ASN1($ssl, $data, $len);
    # $ssl - value corresponding to openssl's SSL structure
    # $data - key data (binary)
    # $len - length of $data
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * use_RSAPrivateKey_file

Adds the first RSA private key found in $file to $ssl.

    my $rv = Net::SSLeay::use_RSAPrivateKey_file($ssl, $file, $type);
    # $ssl - value corresponding to openssl's SSL structure
    # $file - (string) file name
    # $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * use_certificate

Loads the certificate $x into $ssl.

    my $rv = Net::SSLeay::use_certificate($ssl, $x);
    # $ssl - value corresponding to openssl's SSL structure
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * use_certificate_ASN1

Loads the ASN1 encoded certificate from $data to $ssl.

    my $rv = Net::SSLeay::use_certificate_ASN1($ssl, $data, $len);
    # $ssl - value corresponding to openssl's SSL structure
    # $data - certificate data (binary)
    # $len - length of $data
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * use_certificate_chain_file

B<COMPATIBILITY>: not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0

Loads a certificate chain from $file into $ssl. The certificates must be in PEM format and must be sorted
starting with the subject's certificate (actual client or server certificate), followed by intermediate
CA certificates if applicable, and ending at the highest level (root) CA.

    my $rv = Net::SSLeay::use_certificate_chain_file($ssl, $file);
    # $ssl - value corresponding to openssl's SSL structure
    # $file - (string) file name
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * use_certificate_file

Loads the first certificate stored in $file into $ssl.

    my $rv = Net::SSLeay::use_certificate_file($ssl, $file, $type);
    # $ssl - value corresponding to openssl's SSL structure
    # $file - (string) file name
    # $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
    #
    # returns: 1 on success, otherwise check out the error stack to find out the reason

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_certificate.html>

=item * get_version

Returns SSL/TLS protocol name

    my $rv = Net::SSLeay::get_version($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (string) protocol name, see OpenSSL manual for the full list
    #          TLSv1
    #          TLSv1.3

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_get_version.html>

=item * version

Returns SSL/TLS protocol version

    my $rv = Net::SSLeay::version($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (integer) protocol version, see OpenSSL manual for the full list
    #          0x0301 - TLS1_VERSION  (TLSv1)
    #          0xFEFF - DTLS1_VERSION (DTLSv1)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_version.html>

=item * client_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL

Returns TLS protocol version used by the client when initiating the connection

    my $rv = Net::SSLeay::client_version($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (integer) protocol version, see OpenSSL manual for the full list
    #          0x0301 - TLS1_VERSION  (TLSv1)
    #          0xFEFF - DTLS1_VERSION (DTLSv1)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_client_version.html>

=item * is_dtls

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL

    my $rv = Net::SSLeay::is_dtls($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (integer) zero or one
    #          0 - connection is not using DTLS
    #          1 - connection is using DTLS

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_is_dtls.html>

=item * want

Returns state information for the SSL object $ssl.

    my $rv = Net::SSLeay::want($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: state
    #          1 - SSL_NOTHING
    #          2 - SSL_WRITING
    #          3 - SSL_READING
    #          4 - SSL_X509_LOOKUP

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_want.html>

=item * write

Writes data from the buffer $data into the specified $ssl connection.

    my $rv = Net::SSLeay::write($ssl, $data);
    # $ssl - value corresponding to openssl's SSL structure
    # $data - data to be written
    #
    # returns: >0 - (success) number of bytes actually written to the TLS/SSL connection
    #           0 - write not successful, probably the underlying connection was closed
    #          <0 - error

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_write.html>

=item * write_ex

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Writes data from the buffer $data into the specified $ssl connection.

    my ($len, $rv) = Net::SSLeay::write_ex($ssl, $data);
    # $ssl - value corresponding to openssl's SSL structure
    # $data - data to be written
    #
    # returns a list: two-item list consisting of number of bytes written,
    #                 and return code from SSL_write_ex()

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_write_ex.html>

=item * write_partial

B<NOTE:> Does not exactly correspond to any low level API function

Writes a fragment of data in $data from the buffer $data into the specified
$ssl connection. This is a non-blocking function like L<Net::SSLeay::write()>.

    my $rv = Net::SSLeay::write_partial($ssl, $from, $count, $data);
    # $ssl - value corresponding to openssl's SSL structure
    # $from - (integer) offset from the beginning of $data
    # $count - (integer) length of data to be written
    # $data - data buffer
    #
    # returns: >0 - (success) number of bytes actually written to the TLS/SSL connection
    #           0 - write not successful, probably the underlying connection was closed
    #          <0 - error

=item * set_tlsext_host_name

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before; requires at least OpenSSL 0.9.8f

Sets TLS servername extension on SSL object $ssl to value $name.

    my $rv = set_tlsext_host_name($ssl, $name);
    # $ssl - value corresponding to openssl's SSL structure
    # $name - (string) name to be set
    #
    # returns: 1 on success, 0 on failure

=item * client_hello_isv2

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

B<NOTE:> to be used only from a callback set with L<CTX_set_client_hello_cb>.

Indicate if the ClientHello was carried in a SSLv2 record and is in the SSLv2 format.

    my $rv = client_hello_isv2($s);
    # $s - value corresponding to openssl's SSL structure
    #
    # returns: 1 for SSLv2-format ClientHellos and 0 otherwise

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_client_hello_isv2.html>

=item * client_hello_get0_legacy_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

B<NOTE:> to be used only from a callback set with L<CTX_set_client_hello_cb>.

Returns legacy_version, also known as client_version, field from the ClientHello.

    my $rv = client_hello_get0_legacy_version($s);
    # $s - value corresponding to openssl's SSL structure
    #
    # returns: unsigned integer, for example 0x0303 (TLS v1.2) with TLS 1.3

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_client_hello_get0_legacy_version.html>

=item * client_hello_get0_random, client_hello_get0_session_id, client_hello_get0_ciphers and client_hello_get0_compression_methods

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

B<NOTE:> to be used only from a callback set with L<CTX_set_client_hello_cb>.

These functions return random, session_id, cipher_suites and compression_methods fields from the ClientHello, respectively.

    my $random = client_hello_get0_random($s);
    my $session_id = client_hello_get0_session_id($s);
    my $ciphers = client_hello_get0_ciphers($s);
    my $compression_methods = client_hello_get0_compression_methods($s);
    # $s - value corresponding to openssl's SSL structure
    #
    # returns: raw octet data where data length, zero or more, depends on the field definition

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_client_hello_get0_random.html>

=item * client_hello_get1_extensions_present and client_hello_get_extension_order

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

B<NOTE:> to be used only from a callback set with L<CTX_set_client_hello_cb>.

Returns a reference to an array holding the numerical value of the TLS extension types in the order they appear in the ClientHello. client_hello_get_extension_order is similar and requires at least OpenSSL 3.2.0, not in LibreSSL.

    my $ref = client_hello_get1_extensions_present($s);
    # $s - value corresponding to openssl's SSL structure
    #
    # returns: an array reference of zero or more extension types or undef on failure

Example from a TLS 1.3 ClientHello:

    sub client_hello_cb {
        my ($ssl, $arg) = @_;
        my $ref = client_hello_get1_extensions_present($ssl);
        print join(' ', @$ref), "\n" if $ref;
    }

Prints: C<11 10 35 22 23 13 43 45 51>

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_client_hello_get1_extensions_present.html>

=item * client_hello_get0_ext

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1pre1, not in LibreSSL

B<NOTE:> to be used only from a callback set with L<CTX_set_client_hello_cb>.

Returns an extension by type number from the ClientHello.

    my $ref = client_hello_get1_extensions_present($s, $type);
    # $s - value corresponding to openssl's SSL structure
    # $type - (integer) extension type number
    #
    # returns: zero or more octets of extension contents including extension length, undef if the extension is not present

Example: Get the value of TLS extension C<supported_versions>. You can use constant C<TLSEXT_TYPE_supported_versions> or 43 directly.

    sub client_hello_cb {
        my ($ssl, $arg) = @_;
        my $ext_ver = Net::SSLeay::client_hello_get0_ext($ssl, Net::SSLeay::TLSEXT_TYPE_supported_versions());
        print unpack('H*', $ext_ver), "\n" if defined $ext_ver;
    }

Prints: C<080304030303020301> where the first octet 0x08 is the extension length and the following four 16bit values correspond to TLS versions 1.3, 1.2, 1.1 and 1.0.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_client_hello_get0_ext.html>

=back

=head3 Low level API: RAND_* related functions

Check openssl doc related to RAND stuff L<https://www.openssl.org/docs/manmaster/man3/rand.html>

=over

=item * RAND_add

Mixes the $num bytes at $buf into the PRNG state.

    Net::SSLeay::RAND_add($buf, $num, $entropy);
    # $buf - buffer with data to be mixed into the PRNG state
    # $num - number of bytes in $buf
    # $entropy - estimate of how much randomness is contained in $buf (in bytes)
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_add.html>

=item * RAND_seed

Equivalent to L</RAND_add> when $num == $entropy.

    Net::SSLeay::RAND_seed($buf);   # Perlishly figures out buf size
    # $buf - buffer with data to be mixed into the PRNG state
    # $num - number of bytes in $buf
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_add.html>

=item * RAND_status

Gives PRNG status (seeded enough or not).

    my $rv = Net::SSLeay::RAND_status();
    # returns: 1 if the PRNG has been seeded with enough data, 0 otherwise

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_add.html>

=item * RAND_bytes

Puts $num cryptographically strong pseudo-random bytes into $buf.

    my $rv = Net::SSLeay::RAND_bytes($buf, $num);
    # $buf - buffer where the random data will be stored
    # $num - the size (in bytes) of requested random data
    #
    # returns: 1 on success, -1 if not supported by the current RAND method, or 0 on other failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_bytes.html>

=item * RAND_priv_bytes

B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL

Puts $num cryptographically strong pseudo-random bytes into $buf.

    my $rv = Net::SSLeay::RAND_priv_bytes($buf, $num);
    # $buf - buffer where the random data will be stored
    # $num - the size (in bytes) of requested random data
    #
    # returns: 1 on success, -1 if not supported by the current RAND method, or 0 on other failure

RAND_priv_bytes has the same semantics as RAND_bytes, but see see the documentation for more information.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_priv_bytes.html>

=item * RAND_pseudo_bytes

Puts $num pseudo-random (not necessarily unpredictable) bytes into $buf.

    my $rv = Net::SSLeay::RAND_pseudo_bytes($buf, $num);
    # $buf - buffer where the random data will be stored
    # $num - the size (in bytes) of requested random data
    #
    # returns: 1 if the bytes generated are cryptographically strong, 0 otherwise

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_bytes.html>

=item * RAND_cleanup

Erase the PRNG state.

    Net::SSLeay::RAND_cleanup();
    # no args, no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_cleanup.html>

=item * RAND_egd_bytes

Queries the entropy gathering daemon EGD on socket $path for $bytes bytes.

    my $rv = Net::SSLeay::RAND_egd_bytes($path, $bytes);
    # $path - path to a socket of entropy gathering daemon EGD
    # $bytes - number of bytes we want from EGD
    #
    # returns: the number of bytes read from the daemon on success, and -1 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_egd.html>

=item * RAND_file_name

Generates a default path for the random seed file.

    my $file = Net::SSLeay::RAND_file_name($num);
    # $num - maximum size of returned file name
    #
    # returns: string with file name on success, '' (empty string) or undef on failure

LibreSSL and OpenSSL 1.1.0a and later return undef when, for example, $num is not large enough to hold the filename.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_load_file.html>

=item * RAND_load_file

B<COMPATIBILITY:> Is no longer functional on LibreSSL

Reads $max_bytes of bytes from $file_name and adds them to the PRNG.

    my $rv = Net::SSLeay::RAND_load_file($file_name, $max_bytes);
    # $file_name - the name of file
    # $max_bytes - bytes to read from $file_name; -1 => the complete file is read
    #
    # returns: the number of bytes read

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_load_file.html>

=item * RAND_write_file

Writes 1024 random bytes to $file_name which can be used to initialize the PRNG by calling L</RAND_load_file> in a later session.

    my $rv = Net::SSLeay::RAND_write_file($file_name);
    # $file_name - the name of file
    #
    # returns: the number of bytes written, and -1 if the bytes written were generated without appropriate seed

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RAND_load_file.html>

=item * RAND_poll

Collects some entropy from operating system and adds it to the PRNG.

    my $rv = Net::SSLeay::RAND_poll();
    # returns: 1 on success, 0 on failure (unable to gather reasonable entropy)

=back

=head3 Low level API: OBJ_* related functions

=over

=item * OBJ_cmp

Compares ASN1_OBJECT $a to ASN1_OBJECT $b.

    my $rv = Net::SSLeay::OBJ_cmp($a, $b);
    # $a - value corresponding to openssl's ASN1_OBJECT structure
    # $b - value corresponding to openssl's ASN1_OBJECT structure
    #
    # returns: if the two are identical 0 is returned

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OBJ_nid2obj.html>

=item * OBJ_dup

Returns a copy/duplicate of $o.

    my $rv = Net::SSLeay::OBJ_dup($o);
    # $o - value corresponding to openssl's ASN1_OBJECT structure
    #
    # returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OBJ_nid2obj.html>

=item * OBJ_nid2ln

Returns long name for given NID $n.

    my $rv = Net::SSLeay::OBJ_nid2ln($n);
    # $n - (integer) NID
    #
    # returns: (string) long name e.g. 'commonName'

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OBJ_nid2obj.html>

=item * OBJ_ln2nid

Returns NID corresponding to given long name $n.

    my $rv = Net::SSLeay::OBJ_ln2nid($s);
    # $s - (string) long name e.g. 'commonName'
    #
    # returns: (integer) NID

=item * OBJ_nid2sn

Returns short name for given NID $n.

    my $rv = Net::SSLeay::OBJ_nid2sn($n);
    # $n - (integer) NID
    #
    # returns: (string) short name e.g. 'CN'

Example:

    print Net::SSLeay::OBJ_nid2sn(&Net::SSLeay::NID_commonName);

=item * OBJ_sn2nid

Returns NID corresponding to given short name $s.

    my $rv = Net::SSLeay::OBJ_sn2nid($s);
    # $s - (string) short name e.g. 'CN'
    #
    # returns: (integer) NID

Example:

    print "NID_commonName constant=", &Net::SSLeay::NID_commonName;
    print "OBJ_sn2nid('CN')=", Net::SSLeay::OBJ_sn2nid('CN');

=item * OBJ_nid2obj

Returns ASN1_OBJECT for given NID $n.

    my $rv = Net::SSLeay::OBJ_nid2obj($n);
    # $n - (integer) NID
    #
    # returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OBJ_nid2obj.html>

=item * OBJ_obj2nid

Returns NID corresponding to given ASN1_OBJECT $o.

    my $rv = Net::SSLeay::OBJ_obj2nid($o);
    # $o - value corresponding to openssl's ASN1_OBJECT structure
    #
    # returns: (integer) NID

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OBJ_nid2obj.html>

=item * OBJ_txt2obj

Converts the text string s into an ASN1_OBJECT structure. If $no_name is 0 then
long names (e.g. 'commonName') and short names (e.g. 'CN') will be interpreted
as well as numerical forms (e.g. '2.5.4.3'). If $no_name is 1 only the numerical
form is acceptable.

    my $rv = Net::SSLeay::OBJ_txt2obj($s, $no_name);
    # $s - text string to be converted
    # $no_name - (integer) 0 or 1
    #
    # returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OBJ_nid2obj.html>

=item * OBJ_obj2txt

Converts the ASN1_OBJECT a into a textual representation.

    Net::SSLeay::OBJ_obj2txt($a, $no_name);
    # $a - value corresponding to openssl's ASN1_OBJECT structure
    # $no_name - (integer) 0 or 1
    #
    # returns: textual representation e.g. 'commonName' ($no_name=0), '2.5.4.3' ($no_name=1)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OBJ_nid2obj.html>

=item * OBJ_txt2nid

Returns NID corresponding to text string $s which can be a long name, a short name or the numerical representation of an object.

    my $rv = Net::SSLeay::OBJ_txt2nid($s);
    # $s - (string) e.g. 'commonName' or 'CN' or '2.5.4.3'
    #
    # returns: (integer) NID

Example:

    my $nid = Net::SSLeay::OBJ_txt2nid('2.5.4.3');
    Net::SSLeay::OBJ_nid2sn($n);

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OBJ_nid2obj.html>

=back

=head3 Low level API: ASN1_INTEGER_* related functions

=over

=item * ASN1_INTEGER_new

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Creates a new ASN1_INTEGER structure.

    my $rv = Net::SSLeay::ASN1_INTEGER_new();
    #
    # returns: value corresponding to openssl's ASN1_INTEGER structure (0 on failure)

=item * ASN1_INTEGER_free

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Free an allocated ASN1_INTEGER structure.

    Net::SSLeay::ASN1_INTEGER_free($i);
    # $i - value corresponding to openssl's ASN1_INTEGER structure
    #
    # returns: no return value

=item * ASN1_INTEGER_get

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns integer value of given ASN1_INTEGER object.

B<BEWARE:> If the value stored in ASN1_INTEGER is greater than max. integer that can be stored
in 'long' type (usually 32bit but may vary according to platform) then this function will return -1.
For getting large ASN1_INTEGER values consider using L</P_ASN1_INTEGER_get_dec> or L</P_ASN1_INTEGER_get_hex>.

    my $rv = Net::SSLeay::ASN1_INTEGER_get($a);
    # $a - value corresponding to openssl's ASN1_INTEGER structure
    #
    # returns: integer value of ASN1_INTEGER object in $a

=item * ASN1_INTEGER_set

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets value of given ASN1_INTEGER object to value $val

B<BEWARE:> $val has max. limit (= max. integer that can be stored in 'long' type).
For setting large ASN1_INTEGER values consider using L</P_ASN1_INTEGER_set_dec> or L</P_ASN1_INTEGER_set_hex>.

    my $rv = Net::SSLeay::ASN1_INTEGER_set($i, $val);
    # $i - value corresponding to openssl's ASN1_INTEGER structure
    # $val - integer value
    #
    # returns: 1 on success, 0 on failure

=item * P_ASN1_INTEGER_get_dec

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns string with decimal representation of integer value of given ASN1_INTEGER object.

    Net::SSLeay::P_ASN1_INTEGER_get_dec($i);
    # $i - value corresponding to openssl's ASN1_INTEGER structure
    #
    # returns: string with decimal representation

=item * P_ASN1_INTEGER_get_hex

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns string with hexadecimal representation of integer value of given ASN1_INTEGER object.

    Net::SSLeay::P_ASN1_INTEGER_get_hex($i);
    # $i - value corresponding to openssl's ASN1_INTEGER structure
    #
    # returns: string with hexadecimal representation

=item * P_ASN1_INTEGER_set_dec

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets value of given ASN1_INTEGER object to value $val (decimal string, suitable for large integers)

    Net::SSLeay::P_ASN1_INTEGER_set_dec($i, $str);
    # $i - value corresponding to openssl's ASN1_INTEGER structure
    # $str - string with decimal representation
    #
    # returns: 1 on success, 0 on failure

=item * P_ASN1_INTEGER_set_hex

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets value of given ASN1_INTEGER object to value $val (hexadecimal string, suitable for large integers)

    Net::SSLeay::P_ASN1_INTEGER_set_hex($i, $str);
    # $i - value corresponding to openssl's ASN1_INTEGER structure
    # $str - string with hexadecimal representation
    #
    # returns: 1 on success, 0 on failure

=back

=head3 Low level API: ASN1_STRING_* related functions

=over

=item * P_ASN1_STRING_get

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns string value of given ASN1_STRING object.

    Net::SSLeay::P_ASN1_STRING_get($s, $utf8_decode);
    # $s - value corresponding to openssl's ASN1_STRING structure
    # $utf8_decode - [optional] 0 or 1 whether the returned value should be utf8 decoded (default=0)
    #
    # returns: string

    $string = Net::SSLeay::P_ASN1_STRING_get($s);
    # is the same as:
    $string = Net::SSLeay::P_ASN1_STRING_get($s, 0);

=back

=head3 Low level API: ASN1_TIME_* related functions

=over

=item * ASN1_TIME_new

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    my $time = ASN1_TIME_new();
    # returns: value corresponding to openssl's ASN1_TIME structure

=item * ASN1_TIME_free

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    ASN1_TIME_free($time);
    # $time - value corresponding to openssl's ASN1_TIME structure

=item * ASN1_TIME_set

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    ASN1_TIME_set($time, $t);
    # $time - value corresponding to openssl's ASN1_TIME structure
    # $t - time value in seconds since 1.1.1970

B<BEWARE:> It is platform dependent how this function will handle dates after 2038.
Although perl's integer is large enough the internal implementation of this function
is dependent on the size of time_t structure (32bit time_t has problem with 2038).

If you want to safely set date and time after 2038 use function L</P_ASN1_TIME_set_isotime>.

=item * P_ASN1_TIME_get_isotime

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

B<NOTE:> Does not exactly correspond to any low level API function

Gives ISO-8601 string representation of ASN1_TIME structure.

    my $datetime_string = P_ASN1_TIME_get_isotime($time);
    # $time - value corresponding to openssl's ASN1_TIME structure
    #
    # returns: datetime string like '2033-05-16T20:39:37Z' or '' on failure

The output format is compatible with module L<DateTime::Format::RFC3339>

=item * P_ASN1_TIME_set_isotime

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

B<NOTE:> Does not exactly correspond to any low level API function

Sets time and date value of ANS1_time structure.

    my $rv = P_ASN1_TIME_set_isotime($time, $string);
    # $time - value corresponding to openssl's ASN1_TIME structure
    # $string - ISO-8601 timedate string like '2033-05-16T20:39:37Z'
    #
    # returns: 1 on success, 0 on failure

The C<$string> parameter has to be in full form like C<"2012-03-22T23:55:33"> or
C<"2012-03-22T23:55:33Z"> or C<"2012-03-22T23:55:33CET">. Short forms like
C<"2012-03-22T23:55"> or C<"2012-03-22"> are not supported.

=item * P_ASN1_TIME_put2string

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before, has bugs with OpenSSL 0.9.8i

B<NOTE:> Does not exactly correspond to any low level API function

Gives string representation of ASN1_TIME structure.

    my $str = P_ASN1_TIME_put2string($time);
    # $time - value corresponding to openssl's ASN1_TIME structure
    #
    # returns: datetime string like 'May 16 20:39:37 2033 GMT'

=item * P_ASN1_UTCTIME_put2string

B<NOTE:> deprecated function, only for backward compatibility, just an alias
for L</P_ASN1_TIME_put2string>

=back

=head3 Low level API: X509_* related functions

=over

=item * X509_new

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Allocates and initializes a X509 structure.

    my $rv = Net::SSLeay::X509_new();
    #
    # returns: value corresponding to openssl's X509 structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_new.html>

=item * X509_free

Frees up the X509 structure.

    Net::SSLeay::X509_free($a);
    # $a - value corresponding to openssl's X509 structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_new.html>

=item * X509_check_host

B<COMPATIBILITY:> not available in Net-SSLeay-1.68 and before; requires at least OpenSSL 1.0.2. X509_CHECK_FLAG_NEVER_CHECK_SUBJECT requires OpenSSL 1.1.0.

Checks if the certificate Subject Alternative Name (SAN) or Subject CommonName
(CN) matches the specified host name.

    my $rv = Net::SSLeay::X509_check_host($cert, $name, $flags, $peername);
    # $cert - value corresponding to openssl's X509 structure
    # $name - host name to check
    # $flags (optional, default: 0) - can be the bitwise OR of:
    #   &Net::SSLeay::X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
    #   &Net::SSLeay::X509_CHECK_FLAG_NO_WILDCARDS
    #   &Net::SSLeay::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
    #   &Net::SSLeay::X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS
    #   &Net::SSLeay::X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
    #   &Net::SSLeay::X509_CHECK_FLAG_NEVER_CHECK_SUBJECT
    # $peername (optional) - If not omitted and $host matches $cert,
    #                        a copy of the matching SAN or CN from
    #                        the peer certificate is stored in $peername.
    #
    # returns:
    #   1 for a successful match
    #   0 for a failed match
    #  -1 for an internal error
    #  -2 if the input is malformed

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_check_host.html>.

=item * X509_check_email

B<COMPATIBILITY:> not available in Net-SSLeay-1.68 and before; requires at least OpenSSL 1.0.2.

Checks if the certificate matches the specified email address.

    my $rv = Net::SSLeay::X509_check_email($cert, $address, $flags);
    # $cert - value corresponding to openssl's X509 structure
    # $address - email address to check
    # $flags (optional, default: 0) - see X509_check_host()
    #
    # returns: see X509_check_host()

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_check_email.html>.

=item * X509_check_ip

B<COMPATIBILITY:> not available in Net-SSLeay-1.68 and before; requires at least OpenSSL 1.0.2.

Checks if the certificate matches the specified IPv4 or IPv6 address.

    my $rv = Net::SSLeay::X509_check_ip($cert, $address, $flags);
    # $cert - value corresponding to openssl's X509 structure
    # $address - IP address to check in binary format, in network byte order
    # $flags (optional, default: 0) - see X509_check_host()
    #
    # returns: see X509_check_host()

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_check_ip.html>.

=item * X509_check_ip_asc

B<COMPATIBILITY:> not available in Net-SSLeay-1.68 and before; requires at least OpenSSL 1.0.2.

Checks if the certificate matches the specified IPv4 or IPv6 address.

    my $rv = Net::SSLeay::X509_check_ip_asc($cert, $address, $flags);
    # $cert - value corresponding to openssl's X509 structure
    # $address - IP address to check in text representation
    # $flags (optional, default: 0) - see X509_check_host()
    #
    # returns: see X509_check_host()

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_check_ip_asc.html>.

=item * X509_certificate_type

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns bitmask with type of certificate $x.

    my $rv = Net::SSLeay::X509_certificate_type($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: (integer) bitmask with certificate type

    # to decode bitmask returned by this function use these constants:
    # &Net::SSLeay::EVP_PKS_DSA
    # &Net::SSLeay::EVP_PKS_EC
    # &Net::SSLeay::EVP_PKS_RSA
    # &Net::SSLeay::EVP_PKT_ENC
    # &Net::SSLeay::EVP_PKT_EXCH
    # &Net::SSLeay::EVP_PKT_EXP
    # &Net::SSLeay::EVP_PKT_SIGN
    # &Net::SSLeay::EVP_PK_DH
    # &Net::SSLeay::EVP_PK_DSA
    # &Net::SSLeay::EVP_PK_EC
    # &Net::SSLeay::EVP_PK_RSA

=item * X509_digest

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Computes digest/fingerprint of X509 $data using $type hash function.

    my $digest_value = Net::SSLeay::X509_digest($data, $type);
    # $data - value corresponding to openssl's X509 structure
    # $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
    #
    # returns: hash value (binary)

    # to get printable (hex) value of digest use:
    print unpack('H*', $digest_value);

=item * X509_issuer_and_serial_hash

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sort of a checksum of issuer name and serial number of X509 certificate $x.
The result is not a full hash (e.g. sha-1), it is kind-of-a-hash truncated to the size of 'unsigned long' (32 bits).
The resulting value might differ across different openssl versions for the same X509 certificate.

    my $rv = Net::SSLeay::X509_issuer_and_serial_hash($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: number representing checksum

=item * X509_issuer_name_hash

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sort of a checksum of issuer name of X509 certificate $x.
The result is not a full hash (e.g. sha-1), it is kind-of-a-hash truncated to the size of 'unsigned long' (32 bits).
The resulting value might differ across different openssl versions for the same X509 certificate.

    my $rv = Net::SSLeay::X509_issuer_name_hash($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: number representing checksum

=item * X509_subject_name_hash

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sort of a checksum of subject name of X509 certificate $x.
The result is not a full hash (e.g. sha-1), it is kind-of-a-hash truncated to the size of 'unsigned long' (32 bits).
The resulting value might differ across different openssl versions for the same X509 certificate.

    my $rv = Net::SSLeay::X509_subject_name_hash($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: number representing checksum

=item * X509_pubkey_digest

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Computes digest/fingerprint of public key from X509 certificate $data using $type hash function.

    my $digest_value = Net::SSLeay::X509_pubkey_digest($data, $type);
    # $data - value corresponding to openssl's X509 structure
    # $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
    #
    # returns: hash value (binary)

    # to get printable (hex) value of digest use:
    print unpack('H*', $digest_value);

=item * X509_set_issuer_name

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets issuer of X509 certificate $x to $name.

    my $rv = Net::SSLeay::X509_set_issuer_name($x, $name);
    # $x - value corresponding to openssl's X509 structure
    # $name - value corresponding to openssl's X509_NAME structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_set_pubkey

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets public key of X509 certificate $x to $pkey.

    my $rv = Net::SSLeay::X509_set_pubkey($x, $pkey);
    # $x - value corresponding to openssl's X509 structure
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_set_serialNumber

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets serial number of X509 certificate $x to $serial.

    my $rv = Net::SSLeay::X509_set_serialNumber($x, $serial);
    # $x - value corresponding to openssl's X509 structure
    # $serial - value corresponding to openssl's ASN1_INTEGER structure
    #
    # returns: 1 on success, 0 on failure

    # to create $serial value use one of these:
    $serial = Net::SSLeay::P_ASN1_INTEGER_set_hex('45ad6f');
    $serial = Net::SSLeay::P_ASN1_INTEGER_set_dec('7896541238529631478');
    $serial = Net::SSLeay::ASN1_INTEGER_set(45896);

=item * X509_set_subject_name

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets subject of X509 certificate $x to $name.

    my $rv = Net::SSLeay::X509_set_subject_name($x, $name);
    # $x - value corresponding to openssl's X509 structure
    # $name - value corresponding to openssl's X509_NAME structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_set_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Set 'version' value for X509 certificate $ to $version.

    my $rv = Net::SSLeay::X509_set_version($x, $version);
    # $x - value corresponding to openssl's X509 structure
    # $version - (integer) version number
    #
    # returns: 1 on success, 0 on failure

=item * X509_sign

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sign X509 certificate $x with private key $pkey (using digest algorithm $md).

    my $rv = Net::SSLeay::X509_sign($x, $pkey, $md);
    # $x - value corresponding to openssl's X509 structure
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    # $md - value corresponding to openssl's EVP_MD structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_verify

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Verifies X509 object $a using public key $r (pubkey of issuing CA).

    my $rv = Net::SSLeay::X509_verify($x, $r);
    # $x - value corresponding to openssl's X509 structure
    # $r - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: 0 - verify failure, 1 - verify OK, <0 - error

=item * X509_get_ext_count

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns the total number of extensions in X509 object $x.

    my $rv = Net::SSLeay::X509_get_ext_count($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: count of extensions

=item * X509_get_pubkey

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns public key corresponding to given X509 object $x.

    my $rv = Net::SSLeay::X509_get_pubkey($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: value corresponding to openssl's EVP_PKEY structure (0 on failure)

B<NOTE:> This method returns only the public key's key bits, without the
algorithm or parameters.  Use C<X509_get_X509_PUBKEY()> to return the full
public key (SPKI) instead.

=item * X509_get_X509_PUBKEY

B<COMPATIBILITY:> not available in Net-SSLeay-1.72 and before

Returns the full public key (SPKI) of given X509 certificate $x.

    Net::SSLeay::X509_get_X509_PUBKEY($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: public key data in DER format (binary)

=item * X509_get_serialNumber

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns serial number of X509 certificate $x.

    my $rv = Net::SSLeay::X509_get_serialNumber($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: value corresponding to openssl's ASN1_INTEGER structure (0 on failure)

See L</P_ASN1_INTEGER_get_dec>, L</P_ASN1_INTEGER_get_hex> or L</ASN1_INTEGER_get> to decode ASN1_INTEGER object.

=item * X509_get0_serialNumber

B<COMPATIBILITY:> available in Net-SSLeay-1.86 onwards

X509_get0_serialNumber() is the same as X509_get_serialNumber() except it accepts a const parameter and returns a const result.

=item * X509_get_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns 'version' value of given X509 certificate $x.

    my $rv = Net::SSLeay::X509_get_version($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: (integer) version

=item * X509_get_ext

Returns X509_EXTENSION from $x509 based on given position/index.

    my $rv = Net::SSLeay::X509_get_ext($x509, $index);
    # $x509 - value corresponding to openssl's X509 structure
    # $index - (integer) position/index of extension within $x509
    #
    # returns: value corresponding to openssl's X509_EXTENSION structure (0 on failure)

=item * X509_get_ext_by_NID

Returns X509_EXTENSION from $x509 based on given NID.

    my $rv = Net::SSLeay::X509_get_ext_by_NID($x509, $nid, $loc);
    # $x509 - value corresponding to openssl's X509 structure
    # $nid - (integer) NID value
    # $loc - (integer) position to start lookup at
    #
    # returns: position/index of extension, negative value on error
    #          call Net::SSLeay::X509_get_ext($x509, $rv) to get the actual extension

=item * X509_get_fingerprint

Returns fingerprint of certificate $cert.

B<NOTE:> Does not exactly correspond to any low level API function. The implementation
is based on openssl's C<X509_digest()>.

    Net::SSLeay::X509_get_fingerprint($x509, $type);
    # $x509 - value corresponding to openssl's X509 structure
    # $type - (string) digest type, currently supported values:
    #         "md5"
    #         "sha1"
    #         "sha256"
    #         "ripemd160"
    #
    # returns: certificate digest - hexadecimal string (NOT binary data!)

=item * X509_get_issuer_name

Return an X509_NAME object representing the issuer of the certificate $cert.

    my $rv = Net::SSLeay::X509_get_issuer_name($cert);
    # $cert - value corresponding to openssl's X509 structure
    #
    # returns: value corresponding to openssl's X509_NAME structure (0 on failure)

=item * X509_get0_notAfter, X509_getm_notAfter and X509_get_notAfter

B<COMPATIBILITY:> X509_get0_notAfter and X509_getm_notAfter are not available in Net-SSLeay-1.92 and before

Return an object giving the time after which the certificate $cert is not valid.

    my $rv  = Net::SSLeay::X509_get0_notAfter($cert);
    my $rvm = Net::SSLeay::X509_getm_notAfter($cert);
    # $cert - value corresponding to openssl's X509 structure
    #
    # returns: $rv  read-only value corresponding to openssl's ASN1_TIME structure
    #          $rvm mutable   value corresponding to openssl's ASN1_TIME structure

To get human readable/printable form the return value you can use:

    my $time = Net::SSLeay::X509_get_notAfter($cert);
    print "notAfter=", Net::SSLeay::P_ASN1_TIME_get_isotime($time), "\n";

B<NOTE:> X509_get_notAfter is an alias and deprecated in OpenSSL 1.1.0 and later

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_get0_notAfter.html>

=item * X509_get0_notBefore, X509_getm_notBefore and X509_get_notBefore

B<COMPATIBILITY:> X509_get0_notBefore and X509_getm_notBefore are not available in Net-SSLeay-1.92 and before

Return an object giving the time before which the certificate $cert is not valid

    my $rv  = Net::SSLeay::X509_get0_notBefore($cert);
    my $rvm = Net::SSLeay::X509_getm_notBefore($cert);
    # $cert - value corresponding to openssl's X509 structure
    #
    # returns: $rv  read-only value corresponding to openssl's ASN1_TIME structure
    #          $rvm mutable   value corresponding to openssl's ASN1_TIME structure

To get human readable/printable form the return value you can use:

    my $time = Net::SSLeay::X509_get_notBefore($cert);
    print "notBefore=", Net::SSLeay::P_ASN1_TIME_get_isotime($time), "\n";

B<NOTE:> X509_get_notBefore is an alias and deprecated in OpenSSL 1.1.0 and later

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_get0_notBefore.html>

=item * X509_get_subjectAltNames

B<NOTE:> Does not exactly correspond to any low level API function.

Returns the list of alternative subject names from X509 certificate $cert.

    my @rv = Net::SSLeay::X509_get_subjectAltNames($cert);
    # $cert - value corresponding to openssl's X509 structure
    #
    # returns: list containing pairs - name_type (integer), name_value (string)
    #          where name_type can be:
    #          0 - GEN_OTHERNAME
    #          1 - GEN_EMAIL
    #          2 - GEN_DNS
    #          3 - GEN_X400
    #          4 - GEN_DIRNAME
    #          5 - GEN_EDIPARTY
    #          6 - GEN_URI
    #          7 - GEN_IPADD
    #          8 - GEN_RID

Note: type 7 - GEN_IPADD contains the IP address as a packed binary
address. GEN_RID is available in Net-SSLeay-1.90 and later. Maximum
length for returned RID string is currently 2500. Invalid and overly
long RID values are skipped and not returned. GEN_X400 and
GEN_EDIPARTY are not supported and will not be returned even when
present in the certificate.

=item * X509_get_subject_name

Returns the subject of the certificate $cert.

    my $rv = Net::SSLeay::X509_get_subject_name($cert);
    # $cert - value corresponding to openssl's X509 structure
    #
    # returns: value corresponding to openssl's X509_NAME structure (0 on failure)

=item * X509_gmtime_adj

Adjust the ASN1_TIME object to the timestamp (in GMT).

    my $rv = Net::SSLeay::X509_gmtime_adj($s, $adj);
    # $s - value corresponding to openssl's ASN1_TIME structure
    # $adj - timestamp (seconds since 1.1.1970)
    #
    # returns: value corresponding to openssl's ASN1_TIME structure (0 on failure)

B<BEWARE:> this function may fail for dates after 2038 as it is dependent on time_t size on your
system (32bit time_t does not work after 2038). Consider using L</P_ASN1_TIME_set_isotime> instead).

=item * X509_load_cert_crl_file

Takes PEM file and loads all X509 certificates and X509 CRLs from that file into X509_LOOKUP structure.

    my $rv = Net::SSLeay::X509_load_cert_crl_file($ctx, $file, $type);
    # $ctx - value corresponding to openssl's X509_LOOKUP structure
    # $file - (string) file name
    # $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
    #                          if not FILETYPE_PEM then behaves as Net::SSLeay::X509_load_cert_file()
    #
    # returns: 1 on success, 0 on failure

=item * X509_load_cert_file

Loads/adds X509 certificate from $file to X509_LOOKUP structure

    my $rv = Net::SSLeay::X509_load_cert_file($ctx, $file, $type);
    # $ctx - value corresponding to openssl's X509_LOOKUP structure
    # $file - (string) file name
    # $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
    #
    # returns: 1 on success, 0 on failure

=item * X509_load_crl_file

Loads/adds X509 CRL from $file to X509_LOOKUP structure

    my $rv = Net::SSLeay::X509_load_crl_file($ctx, $file, $type);
    # $ctx - value corresponding to openssl's X509_LOOKUP structure
    # $file - (string) file name
    # $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
    #
    # returns: 1 on success, 0 on failure

=item * X509_policy_level_get0_node

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    my $rv = Net::SSLeay::X509_policy_level_get0_node($level, $i);
    # $level - value corresponding to openssl's X509_POLICY_LEVEL structure
    # $i - (integer) index/position
    #
    # returns: value corresponding to openssl's X509_POLICY_NODE structure (0 on failure)

=item * X509_policy_level_node_count

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    my $rv = Net::SSLeay::X509_policy_level_node_count($level);
    # $level - value corresponding to openssl's X509_POLICY_LEVEL structure
    #
    # returns: (integer) node count

=item * X509_policy_node_get0_parent

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    my $rv = Net::SSLeay::X509_policy_node_get0_parent($node);
    # $node - value corresponding to openssl's X509_POLICY_NODE structure
    #
    # returns: value corresponding to openssl's X509_POLICY_NODE structure (0 on failure)

=item * X509_policy_node_get0_policy

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    my $rv = Net::SSLeay::X509_policy_node_get0_policy($node);
    # $node - value corresponding to openssl's X509_POLICY_NODE structure
    #
    # returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)

=item * X509_policy_node_get0_qualifiers

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    my $rv = Net::SSLeay::X509_policy_node_get0_qualifiers($node);
    # $node - value corresponding to openssl's X509_POLICY_NODE structure
    #
    # returns: value corresponding to openssl's STACK_OF(POLICYQUALINFO) structure (0 on failure)

=item * X509_policy_tree_free

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    Net::SSLeay::X509_policy_tree_free($tree);
    # $tree - value corresponding to openssl's X509_POLICY_TREE structure
    #
    # returns: no return value

=item * X509_policy_tree_get0_level

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    my $rv = Net::SSLeay::X509_policy_tree_get0_level($tree, $i);
    # $tree - value corresponding to openssl's X509_POLICY_TREE structure
    # $i - (integer) level index
    #
    # returns: value corresponding to openssl's X509_POLICY_LEVEL structure (0 on failure)

=item * X509_policy_tree_get0_policies

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    my $rv = Net::SSLeay::X509_policy_tree_get0_policies($tree);
    # $tree - value corresponding to openssl's X509_POLICY_TREE structure
    #
    # returns: value corresponding to openssl's STACK_OF(X509_POLICY_NODE) structure (0 on failure)

=item * X509_policy_tree_get0_user_policies

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    my $rv = Net::SSLeay::X509_policy_tree_get0_user_policies($tree);
    # $tree - value corresponding to openssl's X509_POLICY_TREE structure
    #
    # returns: value corresponding to openssl's STACK_OF(X509_POLICY_NODE) structure (0 on failure)

=item * X509_policy_tree_level_count

B<COMPATIBILITY:> no longer available in LibreSSL 3.8.0 and later

??? (more info needed)

    my $rv = Net::SSLeay::X509_policy_tree_level_count($tree);
    # $tree - value corresponding to openssl's X509_POLICY_TREE structure
    #
    # returns: (integer) count

=item * X509_verify_cert_error_string

Returns a human readable error string for verification error $n.

    my $rv = Net::SSLeay::X509_verify_cert_error_string($n);
    # $n - (long) numeric error code
    #
    # returns: error string

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_CTX_get_error.html>

=item * P_X509_add_extensions

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Adds one or more X509 extensions to X509 object $x.

    my $rv = Net::SSLeay::P_X509_add_extensions($x, $ca_cert, $nid, $value);
    # $x - value corresponding to openssl's X509 structure
    # $ca_cert - value corresponding to openssl's X509 structure (issuer's cert - necessary for setting NID_authority_key_identifier)
    # $nid - NID identifying extension to be set
    # $value - extension value
    #
    # returns: 1 on success, 0 on failure

You can set more extensions at once:

    my $rv = Net::SSLeay::P_X509_add_extensions($x509, $ca_cert,
                &Net::SSLeay::NID_key_usage => 'digitalSignature,keyEncipherment',
                &Net::SSLeay::NID_subject_key_identifier => 'hash',
                &Net::SSLeay::NID_authority_key_identifier => 'keyid',
                &Net::SSLeay::NID_authority_key_identifier => 'issuer',
                &Net::SSLeay::NID_basic_constraints => 'CA:FALSE',
                &Net::SSLeay::NID_ext_key_usage => 'serverAuth,clientAuth',
                &Net::SSLeay::NID_netscape_cert_type => 'server',
                &Net::SSLeay::NID_subject_alt_name => 'DNS:s1.dom.com,DNS:s2.dom.com,DNS:s3.dom.com',
          );

=item * P_X509_copy_extensions

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Copies X509 extensions from X509_REQ object to X509 object - handy when you need to turn X509_REQ into X509 certificate.

    Net::SSLeay::P_X509_copy_extensions($x509_req, $x509, $override);
    # $x509_req - value corresponding to openssl's X509_REQ structure
    # $x509 - value corresponding to openssl's X509 structure
    # $override - (integer) flag indication whether to override already existing items in $x509 (default 1)
    #
    # returns: 1 on success, 0 on failure

=item * P_X509_get_crl_distribution_points

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Get the list of CRL distribution points from X509 certificate.

    my @cdp = Net::SSLeay::P_X509_get_crl_distribution_points($x509);
    # $x509 - value corresponding to openssl's X509 structure
    #
    # returns: list of distribution points (usually URLs)

=item * P_X509_get_ext_key_usage

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Gets the list of extended key usage of given X509 certificate $cert.

    my @ext_usage = Net::SSLeay::P_X509_get_ext_key_usage($cert, $format);
    # $cert - value corresponding to openssl's X509 structure
    # $format - choose type of return values: 0=OIDs, 1=NIDs, 2=shortnames, 3=longnames
    #
    # returns: list of values

Examples:

    my @extkeyusage_oid = Net::SSLeay::P_X509_get_ext_key_usage($x509,0);
    # returns for example: ("1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2")

    my @extkeyusage_nid = Net::SSLeay::P_X509_get_ext_key_usage($x509,1);
    # returns for example: (129, 130)

    my @extkeyusage_sn  = Net::SSLeay::P_X509_get_ext_key_usage($x509,2);
    # returns for example: ("serverAuth", "clientAuth")

    my @extkeyusage_ln  = Net::SSLeay::P_X509_get_ext_key_usage($x509,3);
    # returns for example: ("TLS Web Server Authentication",  "TLS Web Client Authentication")

=item * P_X509_get_key_usage

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Gets the list of key usage of given X509 certificate $cert.

    my @keyusage = Net::SSLeay::P_X509_get_key_usage($cert);
    # $cert - value corresponding to openssl's X509 structure
    #
    # returns: list of key usage values which can be none, one or more from the following list:
    #          "digitalSignature"
    #          "nonRepudiation"
    #          "keyEncipherment"
    #          "dataEncipherment"
    #          "keyAgreement"
    #          "keyCertSign"
    #          "cRLSign"
    #          "encipherOnly"
    #          "decipherOnly"

=item * P_X509_get_netscape_cert_type

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Gets the list of Netscape cert types of given X509 certificate $cert.

    Net::SSLeay::P_X509_get_netscape_cert_type($cert);
    # $cert - value corresponding to openssl's X509 structure
    #
    # returns: list of Netscape type values which can be none, one or more from the following list:
    #          "client"
    #          "server"
    #          "email"
    #          "objsign"
    #          "reserved"
    #          "sslCA"
    #          "emailCA"
    #          "objCA"

=item * P_X509_get_pubkey_alg

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns ASN1_OBJECT corresponding to X509 certificate public key algorithm.

    my $rv = Net::SSLeay::P_X509_get_pubkey_alg($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)

To get textual representation use:

    my $alg = Net::SSLeay::OBJ_obj2txt(Net::SSLeay::P_X509_get_pubkey_alg($x509));
    # returns for example: "rsaEncryption"

=item * P_X509_get_signature_alg

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns ASN1_OBJECT corresponding to X509 signature key algorithm.

    my $rv = Net::SSLeay::P_X509_get_signature_alg($x);
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)

To get textual representation use:

    my $alg = Net::SSLeay::OBJ_obj2txt(Net::SSLeay::P_X509_get_signature_alg($x509));
    # returns for example: "sha1WithRSAEncryption"

=item * sk_X509_new_null

Returns a new, empty, STACK_OF(X509) structure.

    my $rv = Net::SSLeay::sk_X509_new_null();
    #
    # returns: value corresponding to openssl's STACK_OF(X509) structure

=item * sk_X509_push

Pushes an X509 structure onto a STACK_OF(X509) structure.

    my $rv = Net::SSLeay::sk_X509_push($sk_x509, $x509);
    # $sk_x509 - value corresponding to openssl's STACK_OF(X509) structure
    # $x509 - value corresponding to openssl's X509 structure
    #
    # returns: total number of elements after the operation, 0 on failure

=item * sk_X509_pop

Pops an single X509 structure from a STACK_OF(X509) structure.

    my $x509 = Net::SSLeay::sk_X509_pop($sk_x509);
    # $sk_x509 - value corresponding to openssl's STACK_OF(X509) structure
    #
    # returns: a pointer to an X509 structure, undef on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/sk_TYPE_pop.html>

=item * sk_X509_shift

Shifts an single X509 structure onto a STACK_OF(X509) structure.

    my $x509 = Net::SSLeay::sk_X509_shift($sk_x509, $x509);
    # $sk_x509 - value corresponding to openssl's STACK_OF(X509) structure
    # $x509 - value corresponding to openssl's X509 structure
    #
    # returns: a pointer to an X509 structure, undef on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/sk_TYPE_shift.html>

=item * sk_X509_unshift

Unshifts an single X509 structure from a STACK_OF(X509) structure.

    my $rv = Net::SSLeay::sk_X509_unshift($sk_x509);
    # $sk_x509 - value corresponding to openssl's STACK_OF(X509) structure
    #
    # returns: total number of elements after the operation, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/sk_TYPE_unshift.html>

=item * sk_X509_insert

Inserts a single X509 structure into a STACK_OF(X509) at the specified index.

    my $rv = Net::SSLeay::sk_X509_insert($sk_x509, $x509, $index);
    # $sk_x509 - value corresponding to openssl's STACK_OF(X509) structure
    # $x509 - value corresponding to openssl's X509 structure
    # $index - integer - 0 based index
    #
    # returns: total number of elements after the operation, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/sk_TYPE_insert.html>

=item * sk_X509_delete

Delete a single X509 structure from a STACK_OF(X509) at the specified index.

    my $x509 = Net::SSLeay::sk_X509_delete($sk_x509, $index);
    # $sk_x509 - value corresponding to openssl's STACK_OF(X509) structure
    # $index - integer - 0 based index
    #
    # returns: a pointer to an X509 structure, undef on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/sk_TYPE_delete.html>

=item * sk_X509_value

Return a single X509 structure from a STACK_OF(X509) at the specified index.

    my $x509 = Net::SSLeay::sk_X509_value($sk_x509, $index);
    # $sk_x509 - value corresponding to openssl's STACK_OF(X509) structure
    # $index - integer - 0 based index
    #
    # returns: a pointer to an X509 structure, undef on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/sk_TYPE_value.html>

=item * sk_X509_num

Return the number of X509 elements in a STACK_OF(X509).

    my $num = Net::SSLeay::sk_X509_num($sk_x509);
    # $sk_x509 - value corresponding to openssl's STACK_OF(X509) structure
    #
    # returns: the number of elements in the stack, -1 if the passed stack is NULL

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/sk_TYPE_num.html>

=back

=head3 Low level API: X509_REQ_* related functions

=over

=item * X509_REQ_new

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Creates a new X509_REQ structure.

    my $rv = Net::SSLeay::X509_REQ_new();
    #
    # returns: value corresponding to openssl's X509_REQ structure (0 on failure)

=item * X509_REQ_free

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Free an allocated X509_REQ structure.

    Net::SSLeay::X509_REQ_free($x);
    # $x - value corresponding to openssl's X509_REQ structure
    #
    # returns: no return value

=item * X509_REQ_add1_attr_by_NID

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Adds an attribute whose name is defined by a NID $nid. The field value to be added is in $bytes.

    my $rv = Net::SSLeay::X509_REQ_add1_attr_by_NID($req, $nid, $type, $bytes);
    # $req - value corresponding to openssl's X509_REQ structure
    # $nid - (integer) NID value
    # $type - (integer) type of data in $bytes (see below)
    # $bytes - data to be set
    #
    # returns: 1 on success, 0 on failure

    # values for $type - use constants:
    # &Net::SSLeay::MBSTRING_UTF8     - $bytes contains utf8 encoded data
    # &Net::SSLeay::MBSTRING_ASC      - $bytes contains ASCII data

=item * X509_REQ_digest

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Computes digest/fingerprint of X509_REQ $data using $type hash function.

    my $digest_value = Net::SSLeay::X509_REQ_digest($data, $type);
    # $data - value corresponding to openssl's X509_REQ structure
    # $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
    #
    # returns: hash value (binary)

    # to get printable (hex) value of digest use:
    print unpack('H*', $digest_value);

=item * X509_REQ_get_attr_by_NID

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Retrieve the next index matching $nid after $lastpos ($lastpos should initially be set to -1).

    my $rv = Net::SSLeay::X509_REQ_get_attr_by_NID($req, $nid, $lastpos=-1);
    # $req - value corresponding to openssl's X509_REQ structure
    # $nid - (integer) NID value
    # $lastpos - [optional] (integer) index where to start search (default -1)
    #
    # returns: index (-1 if there are no more entries)

Note: use L</P_X509_REQ_get_attr> to get the actual attribute value - e.g.

    my $index = Net::SSLeay::X509_REQ_get_attr_by_NID($req, $nid);
    my @attr_values = Net::SSLeay::P_X509_REQ_get_attr($req, $index);

=item * X509_REQ_get_attr_by_OBJ

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Retrieve the next index matching $obj after $lastpos ($lastpos should initially be set to -1).

    my $rv = Net::SSLeay::X509_REQ_get_attr_by_OBJ($req, $obj, $lastpos=-1);
    # $req - value corresponding to openssl's X509_REQ structure
    # $obj - value corresponding to openssl's ASN1_OBJECT structure
    # $lastpos - [optional] (integer) index where to start search (default -1)
    #
    # returns: index (-1 if there are no more entries)

Note: use L</P_X509_REQ_get_attr> to get the actual attribute value - e.g.

    my $index = Net::SSLeay::X509_REQ_get_attr_by_NID($req, $nid);
    my @attr_values = Net::SSLeay::P_X509_REQ_get_attr($req, $index);

=item * X509_REQ_get_attr_count

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns the total number of attributes in $req.

    my $rv = Net::SSLeay::X509_REQ_get_attr_count($req);
    # $req - value corresponding to openssl's X509_REQ structure
    #
    # returns: (integer) items count

=item * X509_REQ_get_pubkey

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns public key corresponding to given X509_REQ object $x.

    my $rv = Net::SSLeay::X509_REQ_get_pubkey($x);
    # $x - value corresponding to openssl's X509_REQ structure
    #
    # returns: value corresponding to openssl's EVP_PKEY structure (0 on failure)

=item * X509_REQ_get_subject_name

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns X509_NAME object corresponding to subject name of given X509_REQ object $x.

    my $rv = Net::SSLeay::X509_REQ_get_subject_name($x);
    # $x - value corresponding to openssl's X509_REQ structure
    #
    # returns: value corresponding to openssl's X509_NAME structure (0 on failure)

=item * X509_REQ_get_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns 'version' value for given X509_REQ object $x.

    my $rv = Net::SSLeay::X509_REQ_get_version($x);
    # $x - value corresponding to openssl's X509_REQ structure
    #
    # returns: (integer) version e.g. 0 = "version 1"

=item * X509_REQ_set_pubkey

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets public key of given X509_REQ object $x to $pkey.

    my $rv = Net::SSLeay::X509_REQ_set_pubkey($x, $pkey);
    # $x - value corresponding to openssl's X509_REQ structure
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_REQ_set_subject_name

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets subject name of given X509_REQ object $x to X509_NAME object $name.

    my $rv = Net::SSLeay::X509_REQ_set_subject_name($x, $name);
    # $x - value corresponding to openssl's X509_REQ structure
    # $name - value corresponding to openssl's X509_NAME structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_REQ_set_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets 'version' of given X509_REQ object $x to $version.

    my $rv = Net::SSLeay::X509_REQ_set_version($x, $version);
    # $x - value corresponding to openssl's X509_REQ structure
    # $version - (integer) e.g. 0 = "version 1"
    #
    # returns: 1 on success, 0 on failure

=item * X509_REQ_sign

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sign X509_REQ object $x with private key $pk (using digest algorithm $md).

    my $rv = Net::SSLeay::X509_REQ_sign($x, $pk, $md);
    # $x - value corresponding to openssl's X509_REQ structure
    # $pk - value corresponding to openssl's EVP_PKEY structure (requestor's private key)
    # $md - value corresponding to openssl's EVP_MD structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_REQ_verify

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Verifies X509_REQ object $x using public key $r (pubkey of requesting party).

    my $rv = Net::SSLeay::X509_REQ_verify($x, $r);
    # $x - value corresponding to openssl's X509_REQ structure
    # $r - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: 0 - verify failure, 1 - verify OK, <0 - error

=item * P_X509_REQ_add_extensions

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Adds one or more X509 extensions to X509_REQ object $x.

    my $rv = Net::SSLeay::P_X509_REQ_add_extensions($x, $nid, $value);
    # $x - value corresponding to openssl's X509_REQ structure
    # $nid - NID identifying extension to be set
    # $value - extension value
    #
    # returns: 1 on success, 0 on failure

You can set more extensions at once:

    my $rv = Net::SSLeay::P_X509_REQ_add_extensions($x509_req,
            &Net::SSLeay::NID_key_usage => 'digitalSignature,keyEncipherment',
            &Net::SSLeay::NID_basic_constraints => 'CA:FALSE',
            &Net::SSLeay::NID_ext_key_usage => 'serverAuth,clientAuth',
            &Net::SSLeay::NID_netscape_cert_type => 'server',
            &Net::SSLeay::NID_subject_alt_name => 'DNS:s1.com,DNS:s2.com',
            &Net::SSLeay::NID_crl_distribution_points => 'URI:http://pki.com/crl1,URI:http://pki.com/crl2',
          );

=item * P_X509_REQ_get_attr

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns attribute value for X509_REQ's attribute at index $n.

    Net::SSLeay::P_X509_REQ_get_attr($req, $n);
    # $req - value corresponding to openssl's X509_REQ structure
    # $n - (integer) attribute index
    #
    # returns: value corresponding to openssl's ASN1_STRING structure

=back

=head3 Low level API: X509_CRL_* related functions

=over

=item * X509_CRL_new

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Creates a new X509_CRL structure.

    my $rv = Net::SSLeay::X509_CRL_new();
    #
    # returns: value corresponding to openssl's X509_CRL structure (0 on failure)

=item * X509_CRL_free

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Free an allocated X509_CRL structure.

    Net::SSLeay::X509_CRL_free($x);
    # $x - value corresponding to openssl's X509_CRL structure
    #
    # returns: no return value

=item * X509_CRL_digest

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Computes digest/fingerprint of X509_CRL $data using $type hash function.

    my $digest_value = Net::SSLeay::X509_CRL_digest($data, $type);
    # $data - value corresponding to openssl's X509_CRL structure
    # $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
    #
    # returns: hash value (binary)

Example:

    my $x509_crl;
    my $md = Net::SSLeay::EVP_get_digestbyname("sha1");
    my $digest_value = Net::SSLeay::X509_CRL_digest($x509_crl, $md);
    # to get printable (hex) value of digest use:
    print "digest=", unpack('H*', $digest_value), "\n";

=item * X509_CRL_get_ext

B<COMPATIBILITY:> not available in Net-SSLeay-1.54 and before

Returns X509_EXTENSION from $x509 based on given position/index.

    my $rv = Net::SSLeay::X509_CRL_get_ext($x509, $index);
    # $x509 - value corresponding to openssl's X509_CRL structure
    # $index - (integer) position/index of extension within $x509
    #
    # returns: value corresponding to openssl's X509_EXTENSION structure (0 on failure)

=item * X509_CRL_get_ext_by_NID

B<COMPATIBILITY:> not available in Net-SSLeay-1.54 and before

Returns X509_EXTENSION from $x509 based on given NID.

    my $rv = Net::SSLeay::X509_CRL_get_ext_by_NID($x509, $nid, $loc);
    # $x509 - value corresponding to openssl's X509_CRL structure
    # $nid - (integer) NID value
    # $loc - (integer) position to start lookup at
    #
    # returns: position/index of extension, negative value on error
    #          call Net::SSLeay::X509_CRL_get_ext($x509, $rv) to get the actual extension

=item * X509_CRL_get_ext_count

B<COMPATIBILITY:> not available in Net-SSLeay-1.54 and before

Returns the total number of extensions in X509_CRL object $x.

    my $rv = Net::SSLeay::X509_CRL_get_ext_count($x);
    # $x - value corresponding to openssl's X509_CRL structure
    #
    # returns: count of extensions

=item * X509_CRL_get_issuer

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns X509_NAME object corresponding to the issuer of X509_CRL $x.

    my $rv = Net::SSLeay::X509_CRL_get_issuer($x);
    # $x - value corresponding to openssl's X509_CRL structure
    #
    # returns: value corresponding to openssl's X509_NAME structure (0 on failure)

See other C<X509_NAME_*> functions to get more info from X509_NAME structure.

=item * X509_CRL_get0_lastUpdate and X509_CRL_get_lastUpdate

B<COMPATIBILITY:> X509_CRL_get0_lastUpdate not available in Net-SSLeay-1.92 and before, X509_CRL_get_lastUpdate not available in Net-SSLeay-1.45 and before

Returns 'lastUpdate' date-time value of X509_CRL object $x.

    my $rv = Net::SSLeay::X509_CRL_get0_lastUpdate($x);
    # $x - value corresponding to openssl's X509_CRL structure
    #
    # returns: read-only value corresponding to openssl's ASN1_TIME structure

B<NOTE:> X509_CRL_get_lastUpdate is an alias and deprecated in OpenSSL 1.1.0 and later

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_CRL_get0_lastUpdate.html>

=item * X509_CRL_get0_nextUpdate and X509_CRL_get_nextUpdate

B<COMPATIBILITY:> X509_CRL_get0_nextUpdate not available in Net-SSLeay-1.92 and before, X509_CRL_get_nextUpdate not available in Net-SSLeay-1.45 and before

Returns 'nextUpdate' date-time value of X509_CRL object $x.

    my $rv = Net::SSLeay::X509_CRL_get0_nextUpdate($x);
    # $x - value corresponding to openssl's X509_CRL structure
    #
    # returns: read-only value corresponding to openssl's ASN1_TIME structure or 0 if 'nextUpdate' is not set

B<NOTE:> X509_CRL_get_nextUpdate is an alias and deprecated in OpenSSL 1.1.0 and later

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_CRL_get0_nextUpdate.html>

=item * X509_CRL_get_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns 'version' value of given X509_CRL structure $x.

    my $rv = Net::SSLeay::X509_CRL_get_version($x);
    # $x - value corresponding to openssl's X509_CRL structure
    #
    # returns: (integer) version

=item * X509_CRL_set_issuer_name

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets the issuer of X509_CRL object $x to X509_NAME object $name.

    my $rv = Net::SSLeay::X509_CRL_set_issuer_name($x, $name);
    # $x - value corresponding to openssl's X509_CRL structure
    # $name - value corresponding to openssl's X509_NAME structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_CRL_set1_lastUpdate and X509_CRL_set_lastUpdate

B<COMPATIBILITY:> X509_CRL_set1_lastUpdate not available in Net-SSLeay-1.92 and before, X509_CRL_set_lastUpdate not available in Net-SSLeay-1.45 and before

Sets 'lastUpdate' value of X509_CRL object $x to $tm.

    my $rv = Net::SSLeay::X509_CRL_set1_lastUpdate($x, $tm);
    # $x - value corresponding to openssl's X509_CRL structure
    # $tm - value corresponding to openssl's ASN1_TIME structure
    #
    # returns: 1 on success, 0 on failure

B<NOTE:> X509_CRL_set_lastUpdate is an alias and deprecated in OpenSSL 1.1.0 and later

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_CRL_set1_lastUpdate.html>

=item * X509_CRL_set1_nextUpdate and X509_CRL_set_nextUpdate

B<COMPATIBILITY:> X509_CRL_set1_nextUpdate not available in Net-SSLeay-1.92 and before, X509_CRL_set_nextUpdate not available in Net-SSLeay-1.45 and before

Sets 'nextUpdate' value of X509_CRL object $x to $tm.

    my $rv = Net::SSLeay::X509_CRL_set1_nextUpdate($x, $tm);
    # $x - value corresponding to openssl's X509_CRL structure
    # $tm - value corresponding to openssl's ASN1_TIME structure
    #
    # returns: 1 on success, 0 on failure

B<NOTE:> X509_CRL_set_nextUpdate is an alias and deprecated in OpenSSL 1.1.0 and later

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_CRL_set1_nextUpdate.html>

=item * X509_CRL_set_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets 'version' value of given X509_CRL structure $x to $version.

    my $rv = Net::SSLeay::X509_CRL_set_version($x, $version);
    # $x - value corresponding to openssl's X509_CRL structure
    # $version - (integer) version number (1 = version 2 CRL)
    #
    # returns: 1 on success, 0 on failure

Note that if you want to use any X509_CRL extension you need to set "version 2 CRL" - C<Net::SSLeay::X509_CRL_set_version($x, 1)>.

=item * X509_CRL_sign

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sign X509_CRL object $x with private key $pkey (using digest algorithm $md).

    my $rv = Net::SSLeay::X509_CRL_sign($x, $pkey, $md);
    # $x - value corresponding to openssl's X509_CRL structure
    # $pkey - value corresponding to openssl's EVP_PKEY structure
    # $md - value corresponding to openssl's EVP_MD structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_CRL_sort

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sorts the data of X509_CRL object so it will be written in serial number order.

    my $rv = Net::SSLeay::X509_CRL_sort($x);
    # $x - value corresponding to openssl's X509_CRL structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_CRL_verify

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Verifies X509_CRL object $a using public key $r (pubkey of issuing CA).

    my $rv = Net::SSLeay::X509_CRL_verify($a, $r);
    # $a - value corresponding to openssl's X509_CRL structure
    # $r - value corresponding to openssl's EVP_PKEY structure
    #
    # returns: 0 - verify failure, 1 - verify OK, <0 - error

=item * P_X509_CRL_add_revoked_serial_hex

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Adds given serial number $serial_hex to X509_CRL object $crl.

    Net::SSLeay::P_X509_CRL_add_revoked_serial_hex($crl, $serial_hex, $rev_time, $reason_code, $comp_time);
    # $crl - value corresponding to openssl's X509_CRL structure
    # $serial_hex - string (hexadecimal) representation of serial number
    # $rev_time - (revocation time) value corresponding to openssl's ASN1_TIME structure
    # $reason_code - [optional] (integer) reason code (see below) - default 0
    # $comp_time - [optional] (compromise time) value corresponding to openssl's ASN1_TIME structure
    #
    # returns: no return value

    # reason codes:
    # 0 - unspecified
    # 1 - keyCompromise
    # 2 - CACompromise
    # 3 - affiliationChanged
    # 4 - superseded
    # 5 - cessationOfOperation
    # 6 - certificateHold
    # 7 - (value 7 is not used)
    # 8 - removeFromCRL
    # 9 - privilegeWithdrawn
    # 10 - aACompromise

=item * P_X509_CRL_get_serial

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns serial number of X509_CRL object.

    my $rv = Net::SSLeay::P_X509_CRL_get_serial($crl);
    # $crl - value corresponding to openssl's X509_CRL structure
    #
    # returns: value corresponding to openssl's ASN1_INTEGER structure (0 on failure)

=item * P_X509_CRL_set_serial

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Sets serial number of X509_CRL object to $crl_number.

    my $rv = Net::SSLeay::P_X509_CRL_set_serial($crl, $crl_number);
    # $crl - value corresponding to openssl's X509_CRL structure
    # $crl_number - value corresponding to openssl's ASN1_INTEGER structure
    #
    # returns: 1 on success, 0 on failure

=item * P_X509_CRL_add_extensions

B<COMPATIBILITY:> not available in Net-SSLeay-1.88 and before

Adds one or more X509 extensions to X509 CRL object $x.

    my $rv = Net::SSLeay::P_X509_CRL_add_extensions($x, $ca_cert, $nid, $value);
    # $x - value corresponding to openssl's X509 CRL structure
    # $ca_cert - value corresponding to openssl's X509 structure (issuer's cert - necessary for setting NID_authority_key_identifier)
    # $nid - NID identifying extension to be set
    # $value - extension value
    #
    # returns: 1 on success, 0 on failure

For more details see L</P_X509_add_extensions>.

=back

=head3 Low level API: X509_EXTENSION_* related functions

=over

=item * X509_EXTENSION_get_critical

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns 'critical' flag of given X509_EXTENSION object $ex.

    my $rv = Net::SSLeay::X509_EXTENSION_get_critical($ex);
    # $ex - value corresponding to openssl's X509_EXTENSION structure
    #
    # returns: (integer) 1 - critical, 0 - noncritical

=item * X509_EXTENSION_get_data

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns value (raw data) of X509_EXTENSION object $ne.

    my $rv = Net::SSLeay::X509_EXTENSION_get_data($ne);
    # $ne - value corresponding to openssl's X509_EXTENSION structure
    #
    # returns: value corresponding to openssl's ASN1_OCTET_STRING structure (0 on failure)

Note: you can use L</P_ASN1_STRING_get> to convert ASN1_OCTET_STRING into perl scalar variable.

=item * X509_EXTENSION_get_object

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns OID (ASN1_OBJECT) of X509_EXTENSION object $ne.

    my $rv = Net::SSLeay::X509_EXTENSION_get_object($ex);
    # $ex - value corresponding to openssl's X509_EXTENSION structure
    #
    # returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)

=item * X509V3_EXT_print

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns string representation of given X509_EXTENSION object $ext.

    Net::SSLeay::X509V3_EXT_print($ext, $flags, $utf8_decode);
    # $ext - value corresponding to openssl's X509_EXTENSION structure
    # $flags - [optional] (integer) Currently the flag argument is unused and should be set to 0
    # $utf8_decode - [optional] 0 or 1 whether the returned value should be utf8 decoded (default=0)
    #
    # returns: no return value

=item * X509V3_EXT_d2i

Parses an extension and returns its internal structure.

    my $rv = Net::SSLeay::X509V3_EXT_d2i($ext);
    # $ext - value corresponding to openssl's X509_EXTENSION structure
    #
    # returns: pointer ???

=back

=head3 Low level API: X509_NAME_* related functions

=over

=item * X509_NAME_ENTRY_get_data

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Retrieves the field value of $ne in and ASN1_STRING structure.

    my $rv = Net::SSLeay::X509_NAME_ENTRY_get_data($ne);
    # $ne - value corresponding to openssl's X509_NAME_ENTRY structure
    #
    # returns: value corresponding to openssl's ASN1_STRING structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_ENTRY_get_object.html>

=item * X509_NAME_ENTRY_get_object

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Retrieves the field name of $ne in and ASN1_OBJECT structure.

    my $rv = Net::SSLeay::X509_NAME_ENTRY_get_object($ne);
    # $ne - value corresponding to openssl's X509_NAME_ENTRY structure
    #
    # returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_ENTRY_get_object.html>

=item * X509_NAME_new

B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and before

Creates a new X509_NAME structure.
Adds a field whose name is defined by a string $field. The field value to be added is in $bytes.

    my $rv = Net::SSLeay::X509_NAME_new();
    #
    # returns: value corresponding to openssl's X509_NAME structure (0 on failure)

=item * X509_NAME_hash

B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and before

Sort of a checksum of issuer name $name.
The result is not a full hash (e.g. sha-1), it is kind-of-a-hash truncated to the size of 'unsigned long' (32 bits).
The resulting value might differ across different openssl versions for the same X509 certificate.

    my $rv = Net::SSLeay::X509_NAME_hash($name);
    # $name - value corresponding to openssl's X509_NAME structure
    #
    # returns: number representing checksum

=item * X509_NAME_add_entry_by_txt

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Adds a field whose name is defined by a string $field. The field value to be added is in $bytes.

    my $rv = Net::SSLeay::X509_NAME_add_entry_by_txt($name, $field, $type, $bytes, $len, $loc, $set);
    # $name - value corresponding to openssl's X509_NAME structure
    # $field - (string) field definition (name) - e.g. "organizationName"
    # $type - (integer) type of data in $bytes (see below)
    # $bytes - data to be set
    # $loc - [optional] (integer) index where the new entry is inserted: if it is -1 (default) it is appended
    # $set - [optional] (integer) determines how the new type is added. If it is 0 (default) a new RDN is created
    #
    # returns: 1 on success, 0 on failure

    # values for $type - use constants:
    # &Net::SSLeay::MBSTRING_UTF8     - $bytes contains utf8 encoded data
    # &Net::SSLeay::MBSTRING_ASC      - $bytes contains ASCII data

Unicode note: when passing non-ascii (unicode) string in $bytes do not forget to set C<$flags = &Net::SSLeay::MBSTRING_UTF8> and encode the perl $string via C<$bytes = encode('utf-8', $string)>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_add_entry_by_txt.html>

=item * X509_NAME_add_entry_by_NID

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Adds a field whose name is defined by a NID $nid. The field value to be added is in $bytes.

    my $rv = Net::SSLeay::X509_NAME_add_entry_by_NID($name, $nid, $type, $bytes, $len, $loc, $set);
    # $name - value corresponding to openssl's X509_NAME structure
    # $nid - (integer) field definition - NID value
    # $type - (integer) type of data in $bytes (see below)
    # $bytes - data to be set
    # $loc - [optional] (integer) index where the new entry is inserted: if it is -1 (default) it is appended
    # $set - [optional] (integer) determines how the new type is added. If it is 0 (default) a new RDN is created
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_add_entry_by_txt.html>

=item * X509_NAME_add_entry_by_OBJ

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Adds a field whose name is defined by a object (OID) $obj . The field value to be added is in $bytes.

    my $rv = Net::SSLeay::X509_NAME_add_entry_by_OBJ($name, $obj, $type, $bytes, $len, $loc, $set);
    # $name - value corresponding to openssl's X509_NAME structure
    # $obj - field definition - value corresponding to openssl's ASN1_OBJECT structure
    # $type - (integer) type of data in $bytes (see below)
    # $bytes - data to be set
    # $loc - [optional] (integer) index where the new entry is inserted: if it is -1 (default) it is appended
    # $set - [optional] (integer) determines how the new type is added. If it is 0 (default) a new RDN is created
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_add_entry_by_txt.html>

=item * X509_NAME_cmp

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Compares two X509_NAME objects.

    my $rv = Net::SSLeay::X509_NAME_cmp($a, $b);
    # $a - value corresponding to openssl's X509_NAME structure
    # $b - value corresponding to openssl's X509_NAME structure
    #
    # returns: 0 if $a matches $b; non zero otherwise

=item * X509_NAME_digest

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Computes digest/fingerprint of X509_NAME $data using $type hash function.

    my $digest_value = Net::SSLeay::X509_NAME_digest($data, $type);
    # $data - value corresponding to openssl's X509_NAME structure
    # $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
    #
    # returns: hash value (binary)

    # to get printable (hex) value of digest use:
    print unpack('H*', $digest_value);

=item * X509_NAME_entry_count

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns the total number of entries in $name.

    my $rv = Net::SSLeay::X509_NAME_entry_count($name);
    # $name - value corresponding to openssl's X509_NAME structure
    #
    # returns: (integer) entries count

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_get_index_by_NID.html>

=item * X509_NAME_get_entry

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Retrieves the X509_NAME_ENTRY from $name corresponding to index $loc. Acceptable values for $loc run
from 0 to C<Net::SSLeay::X509_NAME_entry_count($name) - 1>. The value returned is an internal pointer which must not be freed.

    my $rv = Net::SSLeay::X509_NAME_get_entry($name, $loc);
    # $name - value corresponding to openssl's X509_NAME structure
    # $loc - (integer) index of wanted entry
    #
    # returns: value corresponding to openssl's X509_NAME_ENTRY structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_get_index_by_NID.html>

=item * X509_NAME_print_ex

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns a string with human readable version of $name.

    Net::SSLeay::X509_NAME_print_ex($name, $flags, $utf8_decode);
    # $name - value corresponding to openssl's X509_NAME structure
    # $flags - [optional] conversion flags (default XN_FLAG_RFC2253) - see below
    # $utf8_decode - [optional] 0 or 1 whether the returned value should be utf8 decoded (default=0)
    #
    # returns: string representation of $name

    # available conversion flags - use constants:
    # &Net::SSLeay::XN_FLAG_COMPAT
    # &Net::SSLeay::XN_FLAG_DN_REV
    # &Net::SSLeay::XN_FLAG_DUMP_UNKNOWN_FIELDS
    # &Net::SSLeay::XN_FLAG_FN_ALIGN
    # &Net::SSLeay::XN_FLAG_FN_LN
    # &Net::SSLeay::XN_FLAG_FN_MASK
    # &Net::SSLeay::XN_FLAG_FN_NONE
    # &Net::SSLeay::XN_FLAG_FN_OID
    # &Net::SSLeay::XN_FLAG_FN_SN
    # &Net::SSLeay::XN_FLAG_MULTILINE
    # &Net::SSLeay::XN_FLAG_ONELINE
    # &Net::SSLeay::XN_FLAG_RFC2253
    # &Net::SSLeay::XN_FLAG_SEP_COMMA_PLUS
    # &Net::SSLeay::XN_FLAG_SEP_CPLUS_SPC
    # &Net::SSLeay::XN_FLAG_SEP_MASK
    # &Net::SSLeay::XN_FLAG_SEP_MULTILINE
    # &Net::SSLeay::XN_FLAG_SEP_SPLUS_SPC
    # &Net::SSLeay::XN_FLAG_SPC_EQ

Most likely you will be fine with default:

    Net::SSLeay::X509_NAME_print_ex($name, &Net::SSLeay::XN_FLAG_RFC2253);

Or you might want RFC2253-like output without utf8 chars escaping:

    use Net::SSLeay qw/XN_FLAG_RFC2253 ASN1_STRFLGS_ESC_MSB/;
    my $flag_rfc22536_utf8 = (XN_FLAG_RFC2253) & (~ ASN1_STRFLGS_ESC_MSB);
    my $result = Net::SSLeay::X509_NAME_print_ex($name, $flag_rfc22536_utf8, 1);

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_print_ex.html>

=item * X509_NAME_get_text_by_NID

Retrieves the text from the first entry in name which matches $nid, if no
such entry exists -1 is returned.

B<openssl note:> this is a legacy function which has various limitations which
makes it of minimal use in practice. It can only find the first matching
entry and will copy the contents of the field verbatim: this can be highly
confusing if the target is a multicharacter string type like a BMPString or a UTF8String.

    Net::SSLeay::X509_NAME_get_text_by_NID($name, $nid);
    # $name - value corresponding to openssl's X509_NAME structure
    # $nid - NID value (integer)
    #
    # returns: text value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_get_index_by_NID.html>

=item * X509_NAME_oneline

Return an ASCII version of $name.

    Net::SSLeay::X509_NAME_oneline($name);
    # $name - value corresponding to openssl's X509_NAME structure
    #
    # returns: (string) ASCII version of $name

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_NAME_print_ex.html>

=item * sk_X509_NAME_free

Free an allocated STACK_OF(X509_NAME) structure.

    Net::SSLeay::sk_X509_NAME_free($sk);
    # $sk - value corresponding to openssl's STACK_OF(X509_NAME) structure
    #
    # returns: no return value

=item * sk_X509_NAME_num

Return number of items in STACK_OF(X509_NAME)

    my $rv = Net::SSLeay::sk_X509_NAME_num($sk);
    # $sk - value corresponding to openssl's STACK_OF(X509_NAME) structure
    #
    # returns: number of items

=item * sk_X509_NAME_value

Returns X509_NAME from position $index in STACK_OF(X509_NAME)

    my $rv = Net::SSLeay::sk_X509_NAME_value($sk, $i);
    # $sk - value corresponding to openssl's STACK_OF(X509_NAME) structure
    # $i - (integer) index/position
    #
    # returns: value corresponding to openssl's X509_NAME structure (0 on failure)

=item * add_file_cert_subjects_to_stack

Add a file of certs to a stack. All certs in $file that are not already in the $stackCAs will be added.

    my $rv = Net::SSLeay::add_file_cert_subjects_to_stack($stackCAs, $file);
    # $stackCAs - value corresponding to openssl's STACK_OF(X509_NAME) structure
    # $file - (string) filename
    #
    # returns: 1 on success, 0 on failure

=item * add_dir_cert_subjects_to_stack

Add a directory of certs to a stack. All certs in $dir that are not already in the $stackCAs will be added.

    my $rv = Net::SSLeay::add_dir_cert_subjects_to_stack($stackCAs, $dir);
    # $stackCAs - value corresponding to openssl's STACK_OF(X509_NAME) structure
    # $dir - (string) the directory to append from. All files in this directory will be examined as potential certs. Any that are acceptable to SSL_add_dir_cert_subjects_to_stack() that are not already in the stack will be included.
    #
    # returns: 1 on success, 0 on failure

=back

=head3 Low level API: X509_STORE_* related functions

=over

=item * X509_STORE_CTX_new

returns a newly initialised X509_STORE_CTX structure.

=item * X509_STORE_CTX_init

X509_STORE_CTX_init() sets up an X509_STORE_CTX for a subsequent verification operation.
It must be called before each call to X509_verify_cert().

    my $rv = Net::SSLeay::X509_STORE_CTX_init($x509_store_ctx, $x509_store, $x509, $chain);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure (required)
    # $x509_store - value corresponding to openssl's X509_STORE structure (optional)
    # $x509 - value corresponding to openssl's X509 structure (optional)
    # $chain - value corresponding to openssl's STACK_OF(X509) structure (optional)
    #
    # returns: 1 on success, 0 on failure
    #
    # Note: returns nothing with Net::SSLeay 1.90 and earlier.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_CTX_init.html>

=item * X509_STORE_CTX_free

Frees an X509_STORE_CTX structure.

    Net::SSLeay::X509_STORE_CTX_free($x509_store_ctx);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure

=item * X509_verify_cert

The X509_verify_cert() function attempts to discover and validate a
certificate chain based on parameters in ctx. A complete description
of the process is contained in the verify(1) manual page.

If this function returns 0, use X509_STORE_CTX_get_error to get additional error
information.

    my $rv = Net::SSLeay::X509_verify_cert($x509_store_ctx);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    #
    # returns: 1 if a complete chain can be built and validated, otherwise 0

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_verify_cert.html>

=item * X509_STORE_CTX_get_current_cert

Returns the certificate in ctx which caused the error or 0 if no certificate is relevant.

    my $rv = Net::SSLeay::X509_STORE_CTX_get_current_cert($x509_store_ctx);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    #
    # returns: value corresponding to openssl's X509 structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_CTX_get_error.html>

=item * X509_STORE_CTX_get0_cert

B<COMPATIBILITY>: not available in Net-SSLeay-1.88 and before; requires at least OpenSSL 1.1.0pre6 or LibreSSL 2.7.0

Returns an internal pointer to the certificate being verified by the ctx.

    my $x509 = Net::SSLeay::X509_STORE_CTX_get0_cert($x509_store_ctx);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    #
    # returns: value corresponding to openssl's X509 structure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_CTX_get0_cert.html>

=item * X509_STORE_CTX_get1_chain

Returns a returns a complete validate chain if a previous call to X509_verify_cert() is successful.

    my $rv = Net::SSLeay::X509_STORE_CTX_get1_chain($x509_store_ctx);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    #
    # returns: value corresponding to openssl's STACK_OF(X509) structure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_CTX_get1_chain.html>

=item * X509_STORE_CTX_get_error

Returns the error code of $ctx.

    my $rv = Net::SSLeay::X509_STORE_CTX_get_error($x509_store_ctx);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    #
    # returns: (integer) error code

For more info about error code values check function L</get_verify_result>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_CTX_get_error.html>

=item * X509_STORE_CTX_get_error_depth

Returns the depth of the error. This is a non-negative integer representing
where in the certificate chain the error occurred. If it is zero it occurred
in the end entity certificate, one if it is the certificate which signed
the end entity certificate and so on.

    my $rv = Net::SSLeay::X509_STORE_CTX_get_error_depth($x509_store_ctx);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    #
    # returns: (integer) depth

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_CTX_get_error.html>

=item * X509_STORE_CTX_get_ex_data

Is used to retrieve the information for $idx from $x509_store_ctx.

    my $rv = Net::SSLeay::X509_STORE_CTX_get_ex_data($x509_store_ctx, $idx);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    # $idx - (integer) index for application specific data
    #
    # returns: pointer to ???

=item * X509_STORE_CTX_set_ex_data

Is used to store application data at arg for idx into $x509_store_ctx.

    my $rv = Net::SSLeay::X509_STORE_CTX_set_ex_data($x509_store_ctx, $idx, $data);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    # $idx - (integer) ???
    # $data - (pointer) ???
    #
    # returns: 1 on success, 0 on failure

=item * X509_STORE_CTX_set_cert

Sets the certificate to be verified in $x509_store_ctx to $x.

    Net::SSLeay::X509_STORE_CTX_set_cert($x509_store_ctx, $x);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_CTX_new.html>

=item * X509_STORE_new

Returns a newly initialized X509_STORE structure.

    my $rv = Net::SSLeay::X509_STORE_new();
    #
    # returns: value corresponding to openssl's X509_STORE structure (0 on failure)

=item * X509_STORE_free

Frees an X509_STORE structure

    Net::SSLeay::X509_STORE_free($x509_store);
    # $x509_store - value corresponding to openssl's X509_STORE structure

=item * X509_STORE_add_lookup

Adds a lookup to an X509_STORE for a given lookup method.

    my $method = &Net::SSLeay::X509_LOOKUP_hash_dir;
    my $rv = Net::SSLeay::X509_STORE_add_lookup($x509_store, $method);
    # $method - value corresponding to openssl's X509_LOOKUP_METHOD structure
    # $x509_store - value corresponding to openssl's X509_STORE structure
    #
    # returns: value corresponding to openssl's X509_LOOKUP structure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_add_lookup.html>

=item * X509_STORE_CTX_set_error

Sets the error code of $ctx to $s. For example it might be used in a verification callback to set an error based on additional checks.

    Net::SSLeay::X509_STORE_CTX_set_error($x509_store_ctx, $s);
    # $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
    # $s - (integer) error id
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_STORE_CTX_get_error.html>

=item * X509_STORE_add_cert

Adds X509 certificate $x into the X509_STORE $store.

    my $rv = Net::SSLeay::X509_STORE_add_cert($store, $x);
    # $store - value corresponding to openssl's X509_STORE structure
    # $x - value corresponding to openssl's X509 structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_STORE_add_crl

Adds X509 CRL $x into the X509_STORE $store.

    my $rv = Net::SSLeay::X509_STORE_add_crl($store, $x);
    # $store - value corresponding to openssl's X509_STORE structure
    # $x - value corresponding to openssl's X509_CRL structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_STORE_set1_param

??? (more info needed)

    my $rv = Net::SSLeay::X509_STORE_set1_param($store, $pm);
    # $store - value corresponding to openssl's X509_STORE structure
    # $pm - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_LOOKUP_hash_dir

Returns an X509_LOOKUP structure that instructs an X509_STORE to
load files from a directory containing certificates with filenames
in the format I<hash.N> or crls with filenames in the format I<hash.>B<r>I<N>

    my $rv = Net::SSLeay::X509_LOOKUP_hash_dir();
    #
    # returns: value corresponding to openssl's X509_LOOKUP_METHOD structure, with the hashed directory method

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_load_crl_file.html>

=item * X509_LOOKUP_add_dir

Add a directory to an X509_LOOKUP structure, usually obtained from
X509_STORE_add_lookup.

    my $method = &Net::SSLeay::X509_LOOKUP_hash_dir;
    my $lookup = Net::SSLeay::X509_STORE_add_lookup($x509_store, $method);
    my $type = &Net::SSLeay::X509_FILETYPE_PEM;
    Net::SSLeay::X509_LOOKUP_add_dir($lookup, $dir, $type);
    # $lookup - value corresponding to openssl's X509_LOOKUP structure
    # $dir - string path to a directory
    # $type - constant corresponding to the type of file in the directory - can be X509_FILETYPE_PEM, X509_FILETYPE_DEFAULT, or X509_FILETYPE_ASN1

=item * X509_STORE_set_flags

    Net::SSLeay::X509_STORE_set_flags($ctx, $flags);
    # $ctx - value corresponding to openssl's X509_STORE structure
    # $flags - (unsigned long) flags to be set (bitmask)
    #
    # returns: no return value

    # to create $flags value use corresponding constants like
    $flags = Net::SSLeay::X509_V_FLAG_CRL_CHECK();

For more details about $flags bitmask see L</X509_VERIFY_PARAM_set_flags>.

=item * X509_STORE_set_purpose

    Net::SSLeay::X509_STORE_set_purpose($ctx, $purpose);
    # $ctx - value corresponding to openssl's X509_STORE structure
    # $purpose - (integer) purpose identifier
    #
    # returns: no return value

For more details about $purpose identifier check L</CTX_set_purpose>.

=item * X509_STORE_set_trust

    Net::SSLeay::X509_STORE_set_trust($ctx, $trust);
    # $ctx - value corresponding to openssl's X509_STORE structure
    # $trust - (integer) trust identifier
    #
    # returns: no return value

For more details about $trust identifier check L</CTX_set_trust>.

=back

=head3 Low Level API: X509_INFO related functions

=over

=item * sk_X509_INFO_num

Returns the number of values in a STACK_OF(X509_INFO) structure.

    my $rv = Net::SSLeay::sk_X509_INFO_num($sk_x509_info);
    # $sk_x509_info - value corresponding to openssl's STACK_OF(X509_INFO) structure
    #
    # returns: number of values in $sk_X509_info

=item * sk_X509_INFO_value

Returns the value of a STACK_OF(X509_INFO) structure at a given index.

    my $rv = Net::SSLeay::sk_X509_INFO_value($sk_x509_info, $index);
    # $sk_x509_info - value corresponding to openssl's STACK_OF(X509_INFO) structure
    # $index - index into the stack
    #
    # returns: value corresponding to openssl's X509_INFO structure at the given index

=item * P_X509_INFO_get_x509

Returns the X509 structure stored in an X509_INFO structure.

    my $rv = Net::SSLeay::P_X509_INFO_get_x509($x509_info);
    # $x509_info - value corresponding to openssl's X509_INFO structure
    #
    # returns: value corresponding to openssl's X509 structure

=back

=head3 Low level API: X509_VERIFY_PARAM_* related functions

=over

=item * X509_VERIFY_PARAM_add0_policy

Enables policy checking (it is disabled by default) and adds $policy to the acceptable policy set.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_add0_policy($param, $policy);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $policy - value corresponding to openssl's ASN1_OBJECT structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_add0_table

??? (more info needed)

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_add0_table($param);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_VERIFY_PARAM_add1_host

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2-beta2 or LibreSSL 2.7.0

Adds an additional reference identifier that can match the peer's certificate.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_add1_host($param, $name);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $name - (string) name to be set
    #
    # returns: 1 on success, 0 on failure

See also OpenSSL docs, L</X509_VERIFY_PARAM_set1_host> and
L</X509_VERIFY_PARAM_set_hostflags> for more information, including
wildcard matching.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_clear_flags

Clears the flags $flags in param.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_clear_flags($param, $flags);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $flags - (unsigned long) flags to be set (bitmask)
    #
    # returns: 1 on success, 0 on failure

For more details about $flags bitmask see L</X509_VERIFY_PARAM_set_flags>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_free

Frees up the X509_VERIFY_PARAM structure.

    Net::SSLeay::X509_VERIFY_PARAM_free($param);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: no return value

=item * X509_VERIFY_PARAM_get0_peername

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2-beta2 or LibreSSL 2.7.0

Returns the DNS hostname or subject CommonName from the peer certificate that matched one of the reference identifiers.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_get0_peername($param);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: (string) name e.g. '*.example.com' or undef

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_get_depth

Returns the current verification depth.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_get_depth($param);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: (integer) depth

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_get_flags

Returns the current verification flags.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_get_flags($param);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: (unsigned long) flags to be set (bitmask)

For more details about returned flags bitmask see L</X509_VERIFY_PARAM_set_flags>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set_flags

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set_flags($param, $flags);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $flags - (unsigned long) flags to be set (bitmask)
    #
    # returns: 1 on success, 0 on failure

    # to create $flags value use corresponding constants like
    $flags = Net::SSLeay::X509_V_FLAG_CRL_CHECK();

For more details about $flags bitmask, see the OpenSSL docs below.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_inherit

??? (more info needed)

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_inherit($to, $from);
    # $to - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $from - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_VERIFY_PARAM_lookup

Finds X509_VERIFY_PARAM by name.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_lookup($name);
    # $name - (string) name we want to find
    #
    # returns: value corresponding to openssl's X509_VERIFY_PARAM structure (0 on failure)

=item * X509_VERIFY_PARAM_new

Creates a new X509_VERIFY_PARAM structure.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_new();
    #
    # returns: value corresponding to openssl's X509_VERIFY_PARAM structure (0 on failure)

=item * X509_VERIFY_PARAM_set1

Sets the name of X509_VERIFY_PARAM structure $to to the same value
as the name of X509_VERIFY_PARAM structure $from.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1($to, $from);
    # $to - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $from - value corresponding to openssl's X509_VERIFY_PARAM structure
    #
    # returns: 1 on success, 0 on failure

=item * X509_VERIFY_PARAM_set1_email

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0

Sets the expected RFC822 email address to email.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_email($param, $email);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $email - (string) email to be set
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set1_host

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0

Sets the expected DNS hostname to name clearing any previously specified host name or names.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_host($param, $name);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $name - (string) name to be set
    #
    # returns: 1 on success, 0 on failure

See also OpenSSL docs, L</X509_VERIFY_PARAM_add1_host> and
L</X509_VERIFY_PARAM_set_hostflags> for more information, including
wildcard matching.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set1_ip

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0

Sets the expected IP address to ip.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_ip($param, $ip);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $ip - (binary) 4 octet IPv4 or 16 octet IPv6 address
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set1_ip_asc

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0

Sets the expected IP address to ipasc.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_asc($param, $ipasc);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $ip - (string) IPv4 or IPv6 address
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set1_name

Sets the name of X509_VERIFY_PARAM structure $param to $name.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_name($param, $name);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $name - (string) name to be set
    #
    # returns: 1 on success, 0 on failure

=item * X509_VERIFY_PARAM_set1_policies

Enables policy checking (it is disabled by default) and sets the acceptable policy set to policies.
Any existing policy set is cleared. The policies parameter can be 0 to clear an existing policy set.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_policies($param, $policies);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $policies - value corresponding to openssl's STACK_OF(ASN1_OBJECT) structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set_depth

Sets the maximum verification depth to depth. That is the maximum number of untrusted CA certificates that can appear in a chain.

    Net::SSLeay::X509_VERIFY_PARAM_set_depth($param, $depth);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $depth - (integer) depth to be set
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set_hostflags

B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2-beta2 or LibreSSL 2.7.0

    Net::SSLeay::X509_VERIFY_PARAM_set_hostflags($param, $flags);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $flags - (unsigned int) flags to be set (bitmask)
    #
    # returns: no return value

See also OpenSSL docs,  L</X509_VERIFY_PARAM_add1_host> and L</X509_VERIFY_PARAM_set1_host> for more information.
The flags for controlling wildcard checks and other features are defined in OpenSSL docs.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set_purpose

Sets the verification purpose in $param to $purpose. This determines the acceptable purpose
of the certificate chain, for example SSL client or SSL server.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set_purpose($param, $purpose);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $purpose - (integer) purpose identifier
    #
    # returns: 1 on success, 0 on failure

For more details about $purpose identifier check L</CTX_set_purpose>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set_time

Sets the verification time in $param to $t. Normally the current time is used.

    Net::SSLeay::X509_VERIFY_PARAM_set_time($param, $t);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $t - (time_t) time in seconds since 1.1.1970
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_set_trust

Sets the trust setting in $param to $trust.

    my $rv = Net::SSLeay::X509_VERIFY_PARAM_set_trust($param, $trust);
    # $param - value corresponding to openssl's X509_VERIFY_PARAM structure
    # $trust - (integer) trust identifier
    #
    # returns: 1 on success, 0 on failure

For more details about $trust identifier check L</CTX_set_trust>.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html>

=item * X509_VERIFY_PARAM_table_cleanup

??? (more info needed)

    Net::SSLeay::X509_VERIFY_PARAM_table_cleanup();
    #
    # returns: no return value

=back

=head3 Low level API: Cipher (EVP_CIPHER_*) related functions

=over

=item * EVP_get_cipherbyname

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before

Returns an EVP_CIPHER structure when passed a cipher name.

    my $rv = Net::SSLeay::EVP_get_cipherbyname($name);
    # $name - (string) cipher name e.g. 'aes-128-cbc', 'camellia-256-ecb', 'des-ede', ...
    #
    # returns: value corresponding to openssl's EVP_CIPHER structure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_EncryptInit.html>

=back

=head3 Low level API: Digest (EVP_MD_*) related functions

=over

=item * OpenSSL_add_all_digests

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    Net::SSLeay::OpenSSL_add_all_digests();
    # no args, no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OpenSSL_add_all_algorithms.html>

=item * P_EVP_MD_list_all

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before; requires at least OpenSSL 1.0.0

B<NOTE:> Does not exactly correspond to any low level API function

    my $rv = Net::SSLeay::P_EVP_MD_list_all();
    #
    # returns: arrayref - list of available digest names

The returned digest names correspond to values expected by L</EVP_get_digestbyname>.

Note that some of the digests are available by default and some only after calling L</OpenSSL_add_all_digests>.

=item * EVP_get_digestbyname

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    my $rv = Net::SSLeay::EVP_get_digestbyname($name);
    # $name - string with digest name
    #
    # returns: value corresponding to openssl's EVP_MD structure

    # The $name param can be:
    # md2
    # md4
    # md5
    # mdc2
    # ripemd160
    # sha
    # sha1
    # sha224
    # sha256
    # sha512
    # whirlpool

Or better check the supported digests by calling L</P_EVP_MD_list_all>.

=item * EVP_MD_type

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    my $rv = Net::SSLeay::EVP_MD_type($md);
    # $md - value corresponding to openssl's EVP_MD structure
    #
    # returns: the NID (integer) of the OBJECT IDENTIFIER representing the given message digest

C<EVP_MD_type> is a non-deprecated alias macro of C<EVP_MD_get_type> since OpenSSL 3.0.0.

=item * EVP_MD_size

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    my $rv = Net::SSLeay::EVP_MD_size($md);
    # $md - value corresponding to openssl's EVP_MD structure
    #
    # returns: the size of the message digest in bytes (e.g. 20 for SHA1)

=item * EVP_MD_get0_description

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 3.0.0-beta1, not in LibreSSL

Return description of a message digest.

    my $rv = Net::SSLeay::EVP_MD_get0_description($md);
    # $md - value corresponding to openssl's EVP_MD structure
    #
    # returns: String, a freeform and digest implementation dependent description of the digest for display and human consumption. (e.g. sha256)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_MD_get0_description.html>

=item * EVP_MD_get0_name

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 3.0.0-beta1, not in LibreSSL

Return one name of a message digest.

    my $rv = Net::SSLeay::EVP_MD_get0_description($md);
    # $md - value corresponding to openssl's EVP_MD structure
    #
    # returns: String, the name of the given message digest. For fetched message digests with multiple names, only one of them is returned; it's recommended to use EVP_MD_names_do_all() instead. (e.g. SHA2-256 or SHA256 for the same digest)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_MD_get0_name.html>

=item * EVP_MD_get_type

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 3.0.0-beta1, not in LibreSSL

Return NID value of a message digest.

    my $rv = Net::SSLeay::EVP_MD_get_type($md);
    # $md - value corresponding to openssl's EVP_MD structure
    #
    # returns: Integer, the NID of the OBJECT IDENTIFIER representing the given message digest when passed an EVP_MD structure.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/EVP_MD_get_type.html>

=item * EVP_MD_CTX_md

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    Net::SSLeay::EVP_MD_CTX_md($ctx);
    # $ctx - value corresponding to openssl's EVP_MD_CTX structure
    #
    # returns: value corresponding to openssl's EVP_MD structure

=item * EVP_MD_CTX_create

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Allocates, initializes and returns a digest context.

    my $rv = Net::SSLeay::EVP_MD_CTX_create();
    #
    # returns: value corresponding to openssl's EVP_MD_CTX structure

The complete idea behind EVP_MD_CTX looks like this example:

    Net::SSLeay::OpenSSL_add_all_digests();

    my $md = Net::SSLeay::EVP_get_digestbyname("sha1");
    my $ctx = Net::SSLeay::EVP_MD_CTX_create();
    Net::SSLeay::EVP_DigestInit($ctx, $md);

    while(my $chunk = get_piece_of_data()) {
        Net::SSLeay::EVP_DigestUpdate($ctx,$chunk);
    }

    my $result = Net::SSLeay::EVP_DigestFinal($ctx);
    Net::SSLeay::EVP_MD_CTX_destroy($ctx);

    print "digest=", unpack('H*', $result), "\n"; # print hex value

=item * EVP_DigestInit_ex

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Sets up digest context $ctx to use a digest $type from ENGINE $impl, $ctx must be
initialized before calling this function, type will typically be supplied by a function
such as L</EVP_get_digestbyname>. If $impl is 0 then the default implementation of digest $type is used.

    my $rv = Net::SSLeay::EVP_DigestInit_ex($ctx, $type, $impl);
    # $ctx  - value corresponding to openssl's EVP_MD_CTX structure
    # $type - value corresponding to openssl's EVP_MD structure
    # $impl - value corresponding to openssl's ENGINE structure
    #
    # returns: 1 for success and 0 for failure

=item * EVP_DigestInit

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Behaves in the same way as L</EVP_DigestInit_ex> except the passed context $ctx does not have
to be initialized, and it always uses the default digest implementation.

    my $rv = Net::SSLeay::EVP_DigestInit($ctx, $type);
    # $ctx - value corresponding to openssl's EVP_MD_CTX structure
    # $type - value corresponding to openssl's EVP_MD structure
    #
    # returns: 1 for success and 0 for failure

=item * EVP_MD_CTX_destroy

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Cleans up digest context $ctx and frees up the space allocated to it, it should be
called only on a context created using L</EVP_MD_CTX_create>.

    Net::SSLeay::EVP_MD_CTX_destroy($ctx);
    # $ctx - value corresponding to openssl's EVP_MD_CTX structure
    #
    # returns: no return value

=item * EVP_DigestUpdate

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    my $rv = Net::SSLeay::EVP_DigestUpdate($ctx, $data);
    # $ctx  - value corresponding to openssl's EVP_MD_CTX structure
    # $data - data to be hashed
    #
    # returns: 1 for success and 0 for failure

=item * EVP_DigestFinal_ex

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Retrieves the digest value from $ctx. After calling L</EVP_DigestFinal_ex> no
additional calls to L</EVP_DigestUpdate> can be made, but
L</EVP_DigestInit_ex> can be called to initialize a new digest operation.

    my $digest_value = Net::SSLeay::EVP_DigestFinal_ex($ctx);
    # $ctx - value corresponding to openssl's EVP_MD_CTX structure
    #
    # returns: hash value (binary)

    # to get printable (hex) value of digest use:
    print unpack('H*', $digest_value);

=item * EVP_DigestFinal

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Similar to L</EVP_DigestFinal_ex> except the digest context ctx is automatically cleaned up.

    my $rv = Net::SSLeay::EVP_DigestFinal($ctx);
    # $ctx - value corresponding to openssl's EVP_MD_CTX structure
    #
    # returns: hash value (binary)

    # to get printable (hex) value of digest use:
    print unpack('H*', $digest_value);

=item * MD2

B<COMPATIBILITY:> not supported by default in OpenSSL 1.0.0

Computes MD2 from given $data (all data needs to be loaded into memory)

    my $digest = Net::SSLeay::MD2($data);
    print "digest(hexadecimal)=", unpack('H*', $digest);

=item * MD4

Computes MD4 from given $data (all data needs to be loaded into memory)

    my $digest = Net::SSLeay::MD4($data);
    print "digest(hexadecimal)=", unpack('H*', $digest);

=item * MD5

Computes MD5 from given $data (all data needs to be loaded into memory)

    my $digest = Net::SSLeay::MD5($data);
    print "digest(hexadecimal)=", unpack('H*', $digest);

=item * RIPEMD160

Computes RIPEMD160 from given $data (all data needs to be loaded into memory)

    my $digest = Net::SSLeay::RIPEMD160($data);
    print "digest(hexadecimal)=", unpack('H*', $digest);

=item * SHA1

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Computes SHA1 from given $data (all data needs to be loaded into memory)

    my $digest = Net::SSLeay::SHA1($data);
    print "digest(hexadecimal)=", unpack('H*', $digest);

=item * SHA256

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before; requires at least OpenSSL 0.9.8

Computes SHA256 from given $data (all data needs to be loaded into memory)

    my $digest = Net::SSLeay::SHA256($data);
    print "digest(hexadecimal)=", unpack('H*', $digest);

=item * SHA512

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before; requires at least OpenSSL 0.9.8

Computes SHA512 from given $data (all data needs to be loaded into memory)

    my $digest = Net::SSLeay::SHA512($data);
    print "digest(hexadecimal)=", unpack('H*', $digest);

=item * EVP_Digest

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Computes "any" digest from given $data (all data needs to be loaded into memory)

    my $md = Net::SSLeay::EVP_get_digestbyname("sha1"); # or any other algorithm
    my $digest = Net::SSLeay::EVP_Digest($data, $md);
    print "digest(hexadecimal)=", unpack('H*', $digest);

=item * EVP_sha1

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

    my $md = Net::SSLeay::EVP_sha1();
    #
    # returns: value corresponding to openssl's EVP_MD structure

=item * EVP_sha256

B<COMPATIBILITY:> requires at least OpenSSL 0.9.8

    my $md = Net::SSLeay::EVP_sha256();
    #
    # returns: value corresponding to openssl's EVP_MD structure

=item * EVP_sha512

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before; requires at least OpenSSL 0.9.8

    my $md = Net::SSLeay::EVP_sha512();
    #
    # returns: value corresponding to openssl's EVP_MD structure

=item * EVP_add_digest

    my $rv = Net::SSLeay::EVP_add_digest($digest);
    # $digest - value corresponding to openssl's EVP_MD structure
    #
    # returns: 1 on success, 0 otherwise

=back

=head3 Low level API: CIPHER_* related functions

=over

=item * CIPHER_get_name

B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and before

Returns name of the cipher used.

    my $rv = Net::SSLeay::CIPHER_get_name($cipher);
    # $cipher - value corresponding to openssl's SSL_CIPHER structure
    #
    # returns: (string) cipher name e.g. 'DHE-RSA-AES256-SHA', '(NONE)' if $cipher is undefined.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CIPHER_get_name.html>

Example:

    my $ssl_cipher = Net::SSLeay::get_current_cipher($ssl);
    my $cipher_name = Net::SSLeay::CIPHER_get_name($ssl_cipher);

=item * CIPHER_description

B<COMPATIBILITY:> doesn't work correctly in Net-SSLeay-1.88 and before

Returns a textual description of the cipher used.

    my $rv = Net::SSLeay::CIPHER_description($cipher);
    # $cipher - value corresponding to openssl's SSL_CIPHER structure
    #
    # returns: (string) cipher description e.g. 'DHE-RSA-AES256-SHA SSLv3 Kx=DH Au=RSA Enc=AES(256) Mac=SHA1'

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CIPHER_description.html>

=item * CIPHER_get_bits

B<COMPATIBILITY:> $alg_bits doesn't work correctly in Net-SSLeay-1.88 and before

Returns the number of secret bits used for cipher.

    my $rv = Net::SSLeay::CIPHER_get_bits($cipher, $alg_bits);
    # $cipher - value corresponding to openssl's SSL_CIPHER structure
    # $alg_bits - [optional] empty scalar for storing additional return value
    #
    # returns: (integer) number of secret bits, 0 on error
    #          (integer) in $alg_bits for bits processed by the chosen algorithm

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CIPHER_get_bits.html>

Example:

    # bits and alg_bits are not equal for e.g., TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
    # RFC 8422 name TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
    my $alg_bits;
    my $bits = Net::SSLeay::CIPHER_get_bits($cipher, $alg_bits);
    # my $bits = Net::SSLeay::CIPHER_get_bits($cipher);
    print "bits: $bits, alg_bits: $alg_bits\n";

=item * CIPHER_get_version

B<COMPATIBILITY:> not available in Net-SSLeay-1.88 and before

Returns version of SSL/TLS protocol that first defined the cipher

    my $rv = Net::SSLeay::CIPHER_get_version($cipher);
    # $cipher - value corresponding to openssl's SSL_CIPHER structure
    #
    # returns: (string) cipher name e.g. 'TLSv1/SSLv3' with some libraries, 'TLSv1.0' or 'TLSv1.3', '(NONE)' if $cipher is undefined.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CIPHER_get_version.html>

=item * CIPHER_get_handshake_digest

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.1.1-pre1, not in LibreSSL

Returns version of SSL/TLS protocol that first defined the cipher

    my $rv = Net::SSLeay::CIPHER_get_handshake_digest($cipher);
    # $cipher - value corresponding to openssl's SSL_CIPHER structure
    #
    # returns: A value corresponding to OpenSSL's EVP_MD structure for the digest used during the SSL/TLS handshake when using $cipher.

Check openssl doc L<https://www.openssl.org/docs/ssl/SSL_CIPHER_get_handshake_digest.html>

=item * CIPHER_find

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before; requires at least OpenSSL 1.0.2 or LibreSSL 3.4.0

Returns a SSL_CIPHER structure from the current SSL using a two octet cipher ID.

    my $cipher = Net::SSLeay::CIPHER_find($ssl, $id);
    # $ssl - value corresponding to OpenSSL SSL structure
    # $id - two octet cipher ID.
    #
    # returns: A value corresponding to OpenSSL SSL_CIPHER structure or undef if cipher is not found or an error occurs.

Example that prints 'OpenSSL name is: TLS_AES_128_GCM_SHA256' with
TLSv1.3 when the ciphersuite is enabled:

    # TLS Cipher Suite 0x13, 0x01 is TLS_AES_128_GCM_SHA256
    my $id = pack('n', 0x1301);
    my $cipher =  Net::SSLeay::CIPHER_find($ssl, $id);
    printf("OpenSSL name is: " . Net::SSLeay::CIPHER_get_name($cipher));

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CIPHER_find.html>

=back

=head3 Low level API: BN_* related functions

=over

=item * BN_dup

Creates and returns a new BIGNUM from an existing BIGNUM.

    my $bn = Net::SSLeay::BN_dup($from);
    # $from - value corresponding to BIGNUM structure
    #
    # returns: a new BIGNUM containing the value $from

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BN_dup.html>

=item * BN_clear

Clears BIGNUM data when it is no longer needed.

    Net::SSLeay::BN_clear($bn);
    # $bn - value corresponding to BIGNUM structure
    #
    # returns: nothing. $bn is set to 0.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BN_clear.html>

=item * BN_clear_free

Clears and frees a previously allocated BIGNUM.

    Net::SSLeay::BN_clear_free($bn);
    # $bn - value corresponding to BIGNUM structure
    #
    # returns: nothing. $bn is no longer usable.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BN_clear_free.html>

=item * BN_free

Frees previously a allocated BIGNUM.

    Net::SSLeay::BN_free($bn);
    # $bn - value corresponding to BIGNUM structure
    #
    # returns: nothing. $bn is no longer usable.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BN_free.html>

=back

=head3 Low level API: RSA_* related functions

=over

=item * RSA_generate_key

Generates a key pair and returns it in a newly allocated RSA structure.
The pseudo-random number generator must be seeded prior to calling RSA_generate_key.

    my $rv = Net::SSLeay::RSA_generate_key($bits, $e, $perl_cb, $perl_cb_arg);
    # $bits - (integer) modulus size in bits e.g. 512, 1024, 2048
    # $e - (integer) public exponent, an odd number, typically 3, 17 or 65537
    # $perl_cb - [optional] reference to perl callback function
    # $perl_cb_arg - [optional] data that will be passed to callback function when invoked
    #
    # returns: value corresponding to openssl's RSA structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RSA_generate_key.html>

=item * RSA_free

Frees the RSA structure and its components. The key is erased before the memory is returned to the system.

    Net::SSLeay::RSA_free($r);
    # $r - value corresponding to openssl's RSA structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RSA_new.html>

=item * RSA_get_key_parameters

B<COMPATIBILITY>: not available when OpenSSL is 1.1.0 or later and Net-SSLeay is 1.92 or earlier

Returns a list of pointers to BIGNUMs representing the parameters of
the key in this order: C<(n, e, d, p, q, dmp1, dmq1, iqmp)>

B<Caution>: returned list consists of direct pointers to BIGNUMs. These must
not be freed by the caller. These pointers can be used to duplicate a
BIGNUM, which would need to be blessed as Crypt::OpenSSL::Bignum for further
use. See L<Crypt::OpenSSL::Bignum> and OpenSSL manual for more about
C<bless_pointer> to why C<BN_dup()> is used.

    my (@params) = RSA_get_key_parameters($r);

    my $dup = Net::SSLeay::BN_dup($params[1]);
    my $e = Crypt::OpenSSL::Bignum->bless_pointer($dup);
    print "exponent: ", $e->to_decimal(), "\n";

This function has no equivalent in OpenSSL or LibreSSL but combines
functions C<RSA_get0_key>, C<RSA_get0_factors> and C<RSA_get0_crt_params> for
an easier interface.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/RSA_get0_key.html>

=back

=head3 Low level API: BIO_* related functions

=over

=item * BIO_eof

Returns 1 if the BIO has read EOF, the precise meaning of 'EOF' varies according to the BIO type.

    my $rv = Net::SSLeay::BIO_eof($s);
    # $s - value corresponding to openssl's BIO structure
    #
    # returns: 1 if EOF has been reached 0 otherwise

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_ctrl.html>

=item * BIO_f_ssl

Returns the SSL BIO method. This is a filter BIO which is a wrapper
round the OpenSSL SSL routines adding a BIO 'flavour' to SSL I/O.

    my $rv = Net::SSLeay::BIO_f_ssl();
    #
    # returns: value corresponding to openssl's BIO_METHOD structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_f_ssl.html>

=item * BIO_free

Frees up a single BIO.

    my $rv = Net::SSLeay::BIO_free($bio);
    # $bio; - value corresponding to openssl's BIO structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_new.html>

=item * BIO_new

Returns a new BIO using method $type

    my $rv = Net::SSLeay::BIO_new($type);
    # $type - value corresponding to openssl's BIO_METHOD structure
    #
    # returns: value corresponding to openssl's BIO structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_new.html>

=item * BIO_new_buffer_ssl_connect

Creates a new BIO chain consisting of a buffering BIO, an SSL BIO (using ctx) and a connect BIO.

    my $rv = Net::SSLeay::BIO_new_buffer_ssl_connect($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: value corresponding to openssl's BIO structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_f_ssl.html>

=item * BIO_new_file

Creates a new file BIO with mode $mode the meaning of mode is the same
as the stdio function fopen(). The BIO_CLOSE flag is set on the returned BIO.

    my $rv = Net::SSLeay::BIO_new_file($filename, $mode);
    # $filename - (string) filename
    # $mode - (string) opening mode (as mode by stdio function fopen)
    #
    # returns: value corresponding to openssl's BIO structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_s_file.html>

=item * BIO_new_ssl

Allocates an SSL BIO using SSL_CTX ctx and using client mode if client is non zero.

    my $rv = Net::SSLeay::BIO_new_ssl($ctx, $client);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $client - (integer) 0 or 1 - indicates ssl client mode
    #
    # returns: value corresponding to openssl's BIO structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_f_ssl.html>

=item * BIO_new_ssl_connect

Creates a new BIO chain consisting of an SSL BIO (using ctx) followed by a connect BIO.

    my $rv = Net::SSLeay::BIO_new_ssl_connect($ctx);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    #
    # returns: value corresponding to openssl's BIO structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_f_ssl.html>

=item * BIO_pending

Return the number of pending characters in the BIOs read buffers.

    my $rv = Net::SSLeay::BIO_pending($s);
    # $s - value corresponding to openssl's BIO structure
    #
    # returns: the amount of pending data

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_ctrl.html>

=item * BIO_wpending

Return the number of pending characters in the BIOs write buffers.

    my $rv = Net::SSLeay::BIO_wpending($s);
    # $s - value corresponding to openssl's BIO structure
    #
    # returns: the amount of pending data

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_ctrl.html>

=item * BIO_read

Read the underlying descriptor.

    Net::SSLeay::BIO_read($s, $max);
    # $s - value corresponding to openssl's BIO structure
    # $max - [optional] max. bytes to read (if not specified, the value 32768 is used)
    #
    # returns: data

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_read.html>

=item * BIO_write

Attempts to write data from $buffer to BIO $b.

    my $rv = Net::SSLeay::BIO_write($b, $buffer);
    # $b - value corresponding to openssl's BIO structure
    # $buffer - data
    #
    # returns: amount of data successfully written
    #          or that no data was successfully read or written if the result is 0 or -1
    #          or -2 when the operation is not implemented in the specific BIO type

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_read.html>

=item * BIO_s_mem

Return the memory BIO method function.

    my $rv = Net::SSLeay::BIO_s_mem();
    #
    # returns: value corresponding to openssl's BIO_METHOD structure (0 on failure)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_s_mem.html>

=item * BIO_ssl_copy_session_id

Copies an SSL session id between BIO chains from and to. It does this by locating
the SSL BIOs in each chain and calling SSL_copy_session_id() on the internal SSL pointer.

    my $rv = Net::SSLeay::BIO_ssl_copy_session_id($to, $from);
    # $to - value corresponding to openssl's BIO structure
    # $from - value corresponding to openssl's BIO structure
    #
    # returns: 1 on success, 0 on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_f_ssl.html>

=item * BIO_ssl_shutdown

Closes down an SSL connection on BIO chain bio. It does this by locating the
SSL BIO in the chain and calling SSL_shutdown() on its internal SSL pointer.

    Net::SSLeay::BIO_ssl_shutdown($ssl_bio);
    # $ssl_bio - value corresponding to openssl's BIO structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/BIO_f_ssl.html>

=back

=head3 Low level API: Server side Server Name Indication (SNI) support

=over

=item * set_tlsext_host_name

TBA

=item * get_servername

TBA

=item * get_servername_type

TBA

=item * CTX_set_tlsext_servername_callback

B<COMPATIBILITY:> requires at least OpenSSL 0.9.8f

This function is used in a server to support Server side Server Name Indication (SNI).

    Net::SSLeay::CTX_set_tlsext_servername_callback($ctx, $code);
    # $ctx - SSL context
    # $code - reference to a subroutine that will be called when a new connection is being initiated
    #
    # returns: no return value

On the client side:
use set_tlsext_host_name($ssl, $servername) before initiating the SSL connection.

On the server side:
Set up an additional SSL_CTX() for each different certificate.

Add a servername callback to each SSL_CTX() using CTX_set_tlsext_servername_callback().

The callback function is required to retrieve the client-supplied servername
with get_servername(ssl). Figure out the right
SSL_CTX to go with that host name, then switch the SSL object to that SSL_CTX
with set_SSL_CTX().

Example:

    # set callback
    Net::SSLeay::CTX_set_tlsext_servername_callback($ctx,
        sub {
            my $ssl = shift;
            my $h = Net::SSLeay::get_servername($ssl);
            Net::SSLeay::set_SSL_CTX($ssl, $hostnames{$h}->{ctx}) if exists $hostnames{$h};
        } );

More complete example:

    # ... initialize Net::SSLeay

    my %hostnames = (
        'sni1' => { cert=>'sni1.pem', key=>'sni1.key' },
        'sni2' => { cert=>'sni2.pem', key=>'sni2.key' },
    );

    # create a new context for each certificate/key pair
    for my $name (keys %hostnames) {
        $hostnames{$name}->{ctx} = Net::SSLeay::CTX_new or die;
        Net::SSLeay::CTX_set_cipher_list($hostnames{$name}->{ctx}, 'ALL');
        Net::SSLeay::set_cert_and_key($hostnames{$name}->{ctx},
        $hostnames{$name}->{cert}, $hostnames{$name}->{key}) or die;
    }

    # create default context
    my $ctx = Net::SSLeay::CTX_new or die;
    Net::SSLeay::CTX_set_cipher_list($ctx, 'ALL');
    Net::SSLeay::set_cert_and_key($ctx, 'cert.pem','key.pem') or die;

    # set callback
    Net::SSLeay::CTX_set_tlsext_servername_callback($ctx, sub {
        my $ssl = shift;
        my $h = Net::SSLeay::get_servername($ssl);
        Net::SSLeay::set_SSL_CTX($ssl, $hostnames{$h}->{ctx}) if exists $hostnames{$h};
    } );

    # ... later

    $s = Net::SSLeay::new($ctx);
    Net::SSLeay::set_fd($s, fileno($accepted_socket));
    Net::SSLeay::accept($s);

=back

=head3 Low level API: NPN (next protocol negotiation) related functions

NPN is being replaced with ALPN, a more recent TLS extension for application
protocol negotiation that's in process of being adopted by IETF. Please look
below for APLN API description.

Simple approach for using NPN support looks like this:

    ### client side
    use Net::SSLeay;
    use IO::Socket::INET;

    Net::SSLeay::initialize();
    my $sock = IO::Socket::INET->new(PeerAddr=>'encrypted.google.com:443') or die;
    my $ctx = Net::SSLeay::CTX_tlsv1_new() or die;
    Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL);
    Net::SSLeay::CTX_set_next_proto_select_cb($ctx, ['http1.1','spdy/2']);
    my $ssl = Net::SSLeay::new($ctx) or die;
    Net::SSLeay::set_fd($ssl, fileno($sock)) or die;
    Net::SSLeay::connect($ssl);

    warn "client:negotiated=",Net::SSLeay::P_next_proto_negotiated($ssl), "\n";
    warn "client:last_status=", Net::SSLeay::P_next_proto_last_status($ssl), "\n";

    ### server side
    use Net::SSLeay;
    use IO::Socket::INET;

    Net::SSLeay::initialize();
    my $ctx = Net::SSLeay::CTX_tlsv1_new() or die;
    Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL);
    Net::SSLeay::set_cert_and_key($ctx, "cert.pem", "key.pem");
    Net::SSLeay::CTX_set_next_protos_advertised_cb($ctx, ['spdy/2','http1.1']);
    my $sock = IO::Socket::INET->new(LocalAddr=>'localhost', LocalPort=>5443, Proto=>'tcp', Listen=>20) or die;

    while (1) {
        my $ssl = Net::SSLeay::new($ctx);
        warn("server:waiting for incoming connection...\n");
        my $fd = $sock->accept();
        Net::SSLeay::set_fd($ssl, $fd->fileno);
        Net::SSLeay::accept($ssl);
        warn "server:negotiated=",Net::SSLeay::P_next_proto_negotiated($ssl),"\n";
        my $got = Net::SSLeay::read($ssl);
        Net::SSLeay::ssl_write_all($ssl, "length=".length($got));
        Net::SSLeay::free($ssl);
        $fd->close();
    }
    # check with: openssl s_client -connect localhost:5443 -nextprotoneg http/1.1,spdy/2

Please note that the selection (negotiation) is performed by client side, the server side simply advertise the list of supported protocols.

Advanced approach allows you to implement your own negotiation algorithm.

    # see below documentation for:
    Net::SSLeay::CTX_set_next_proto_select_cb($ctx, $perl_callback_function, $callback_data);
    Net::SSLeay::CTX_set_next_protos_advertised_cb($ctx, $perl_callback_function, $callback_data);

Detection of NPN support (works even in older Net::SSLeay versions):

    use Net::SSLeay;

    if (exists &Net::SSLeay::P_next_proto_negotiated) {
        # do NPN stuff
    }

=over

=item * CTX_set_next_proto_select_cb

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before; requires at least OpenSSL 1.0.1

B<NOTE:> You need CTX_set_next_proto_select_cb on B<client side> of SSL connection.

Simple usage - in this case a "common" negotiation algorithm (as implemented by openssl's function SSL_select_next_proto) is used.

    $rv = Net::SSLeay::CTX_set_next_proto_select_cb($ctx, $arrayref);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $arrayref - list of accepted protocols - e.g. ['http1.0', 'http1.1']
    #
    # returns: 0 on success, 1 on failure

Advanced usage (you probably do not need this):

    $rv = Net::SSLeay::CTX_set_next_proto_select_cb($ctx, $perl_callback_function, $callback_data);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $perl_callback_function - reference to perl function
    # $callback_data - [optional] data to passed to callback function when invoked
    #
    # returns: 0 on success, 1 on failure

    # where callback function looks like
    sub npn_advertised_cb_invoke {
        my ($ssl, $arrayref_proto_list_advertised_by_server, $callback_data) = @_;
        my $status;
        # ...
        $status = 1;   # status can be:
                      # 0 - OPENSSL_NPN_UNSUPPORTED
                      # 1 - OPENSSL_NPN_NEGOTIATED
                      # 2 - OPENSSL_NPN_NO_OVERLAP
        return $status, ['http1.1','spdy/2']; # the callback has to return 2 values
    }

To undefine/clear this callback use:

    Net::SSLeay::CTX_set_next_proto_select_cb($ctx, undef);

=item * CTX_set_next_protos_advertised_cb

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before; requires at least OpenSSL 1.0.1

B<NOTE:> You need CTX_set_next_proto_select_cb on B<server side> of SSL connection.

Simple usage:

    $rv = Net::SSLeay::CTX_set_next_protos_advertised_cb($ctx, $arrayref);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $arrayref - list of advertised protocols - e.g. ['http1.0', 'http1.1']
    #
    # returns: 0 on success, 1 on failure

Advanced usage (you probably do not need this):

    $rv = Net::SSLeay::CTX_set_next_protos_advertised_cb($ctx, $perl_callback_function, $callback_data);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $perl_callback_function - reference to perl function
    # $callback_data - [optional] data to passed to callback function when invoked
    #
    # returns: 0 on success, 1 on failure

    # where callback function looks like
    sub npn_advertised_cb_invoke {
        my ($ssl, $callback_data) = @_;
        # ...
        return ['http1.1','spdy/2']; # the callback has to return arrayref
    }

To undefine/clear this callback use:

    Net::SSLeay::CTX_set_next_protos_advertised_cb($ctx, undef);

=item * P_next_proto_negotiated

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before; requires at least OpenSSL 1.0.1

Returns the name of negotiated protocol for given SSL connection $ssl.

    $rv = Net::SSLeay::P_next_proto_negotiated($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (string) negotiated protocol name (or undef if no negotiation was done or failed with fatal error)

=item * P_next_proto_last_status

B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and before; requires at least OpenSSL 1.0.1

Returns the result of the last negotiation for given SSL connection $ssl.

    $rv = Net::SSLeay::P_next_proto_last_status($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (integer) negotiation status
    #          0 - OPENSSL_NPN_UNSUPPORTED
    #          1 - OPENSSL_NPN_NEGOTIATED
    #          2 - OPENSSL_NPN_NO_OVERLAP

=back

=head3 Low level API: ALPN (application layer protocol negotiation) related functions

Application protocol can be negotiated via two different mechanisms employing
two different TLS extensions: NPN (obsolete) and ALPN (recommended).

The API is rather similar, with slight differences reflecting protocol
specifics. In particular, with ALPN the protocol negotiation takes place on
server, while with NPN the client implements the protocol negotiation logic.

With ALPN, the most basic implementation looks like this:

    ### client side
    use Net::SSLeay;
    use IO::Socket::INET;

    Net::SSLeay::initialize();
    my $sock = IO::Socket::INET->new(PeerAddr=>'encrypted.google.com:443') or die;
    my $ctx = Net::SSLeay::CTX_tlsv1_new() or die;
    Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL);
    Net::SSLeay::CTX_set_alpn_protos($ctx, ['http/1.1', 'http/2.0', 'spdy/3']);
    my $ssl = Net::SSLeay::new($ctx) or die;
    Net::SSLeay::set_fd($ssl, fileno($sock)) or die;
    Net::SSLeay::connect($ssl);

    warn "client:selected=",Net::SSLeay::P_alpn_selected($ssl), "\n";

    ### server side
    use Net::SSLeay;
    use IO::Socket::INET;

    Net::SSLeay::initialize();
    my $ctx = Net::SSLeay::CTX_tlsv1_new() or die;
    Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL);
    Net::SSLeay::set_cert_and_key($ctx, "cert.pem", "key.pem");
    Net::SSLeay::CTX_set_alpn_select_cb($ctx, ['http/1.1', 'http/2.0', 'spdy/3']);
    my $sock = IO::Socket::INET->new(LocalAddr=>'localhost', LocalPort=>5443, Proto=>'tcp', Listen=>20) or die;

    while (1) {
        my $ssl = Net::SSLeay::new($ctx);
        warn("server:waiting for incoming connection...\n");
        my $fd = $sock->accept();
        Net::SSLeay::set_fd($ssl, $fd->fileno);
        Net::SSLeay::accept($ssl);
        warn "server:selected=",Net::SSLeay::P_alpn_selected($ssl),"\n";
        my $got = Net::SSLeay::read($ssl);
        Net::SSLeay::ssl_write_all($ssl, "length=".length($got));
        Net::SSLeay::free($ssl);
        $fd->close();
    }
    # check with: openssl s_client -connect localhost:5443 -alpn spdy/3,http/1.1

Advanced approach allows you to implement your own negotiation algorithm.

    # see below documentation for:
    Net::SSLeay::CTX_set_alpn_select_cb($ctx, $perl_callback_function, $callback_data);

Detection of ALPN support (works even in older Net::SSLeay versions):

    use Net::SSLeay;

    if (exists &Net::SSLeay::P_alpn_selected) {
        # do ALPN stuff
    }

=over

=item * CTX_set_alpn_select_cb

B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and before; requires at least OpenSSL 1.0.2

B<NOTE:> You need CTX_set_alpn_select_cb on B<server side> of TLS connection.

Simple usage - in this case a "common" negotiation algorithm (as implemented by openssl's function SSL_select_next_proto) is used.

    $rv = Net::SSLeay::CTX_set_alpn_select_cb($ctx, $arrayref);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $arrayref - list of accepted protocols - e.g. ['http/2.0', 'http/1.1', 'spdy/3']
    #
    # returns: 0 on success, 1 on failure

Advanced usage (you probably do not need this):

    $rv = Net::SSLeay::CTX_set_alpn_select_cb($ctx, $perl_callback_function, $callback_data);
    # $ctx - value corresponding to openssl's SSL_CTX structure
    # $perl_callback_function - reference to perl function
    # $callback_data - [optional] data to passed to callback function when invoked
    #
    # returns: 0 on success, 1 on failure

    # where callback function looks like
    sub alpn_select_cb_invoke {
        my ($ssl, $arrayref_proto_list_advertised_by_client, $callback_data) = @_;
        # ...
        if ($negotiated) {
            return 'http/2.0';
        } else {
            return undef;
        }
    }

To undefine/clear this callback use:

    Net::SSLeay::CTX_set_alpn_select_cb($ctx, undef);

=item * set_alpn_protos

B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and before; requires at least OpenSSL 1.0.2

B<NOTE:> You need set_alpn_protos on B<client side> of TLS connection.

This adds list of supported application layer protocols to ClientHello message sent by a client.
It advertises the enumeration of supported protocols:

    Net::SSLeay::set_alpn_protos($ssl, ['http/1.1', 'http/2.0', 'spdy/3']);
    # returns 0 on success

=item * CTX_set_alpn_protos

B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and before; requires at least OpenSSL 1.0.2

B<NOTE:> You need CTX_set_alpn_protos on B<client side> of TLS connection.

This adds list of supported application layer protocols to ClientHello message sent by a client.
It advertises the enumeration of supported protocols:

    Net::SSLeay::CTX_set_alpn_protos($ctx, ['http/1.1', 'http/2.0', 'spdy/3']);
    # returns 0 on success

=item * P_alpn_selected

B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and before; requires at least OpenSSL 1.0.2

Returns the name of negotiated protocol for given TLS connection $ssl.

    $rv = Net::SSLeay::P_alpn_selected($ssl);
    # $ssl - value corresponding to openssl's SSL structure
    #
    # returns: (string) negotiated protocol name (or undef if no negotiation was done or failed with fatal error)

=back

=head3 Low level API: DANE Support

OpenSSL version 1.0.2 adds preliminary support RFC6698 Domain Authentication of
Named Entities (DANE) Transport Layer Association within OpenSSL

=over

=item * SSL_get_tlsa_record_byname

B<COMPATIBILITY:> DELETED from net-ssleay, since it is not supported by OpenSSL

In order to facilitate DANE there is additional interface,
SSL_get_tlsa_record_byname, accepting hostname, port and socket type
that returns packed TLSA record. In order to make it even easier there
is additional SSL_ctrl function that calls SSL_get_tlsa_record_byname
for you. Latter is recommended for programmers that wish to maintain
broader binary compatibility, e.g. make application work with both 1.0.2
and prior version (in which case call to SSL_ctrl with new code
returning error would have to be ignored when running with prior version).

    Net::SSLeay::get_tlsa_record_byname($name, $port, $type);

=back

=head3 Low level API: Other functions

=over

=item * COMP_add_compression_method

Adds the compression method cm with the identifier id to the list of available compression methods.
This list is globally maintained for all SSL operations within this application.
It cannot be set for specific SSL_CTX or SSL objects.

    my $rv = Net::SSLeay::COMP_add_compression_method($id, $cm);
    # $id - (integer) compression method id
    #       0 to 63:    methods defined by the IETF
    #       64 to 192:  external party methods assigned by IANA
    #       193 to 255: reserved for private use
    #
    # $cm - value corresponding to openssl's COMP_METHOD structure
    #
    # returns: 0 on success, 1 on failure (check the error queue to find out the reason)

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_COMP_add_compression_method.html>

=item * DH_free

Frees the DH structure and its components. The values are erased before the memory is returned to the system.

    Net::SSLeay::DH_free($dh);
    # $dh - value corresponding to openssl's DH structure
    #
    # returns: no return value

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/DH_new.html>

=item * FIPS_mode_set

Enable or disable FIPS mode in a FIPS capable OpenSSL.

    Net::SSLeay::FIPS_mode_set($enable);
    # $enable - (integer) 1 to enable, 0 to disable

=back

=head3 Low level API: EC related functions

=over

=item * CTX_set_tmp_ecdh

TBA

=item * EC_KEY_free

TBA

=item * EC_KEY_new_by_curve_name

TBA

=item * EC_KEY_generate_key

Generates a EC key and returns it in a newly allocated EC_KEY structure.
The EC key then can be used to create a PKEY which can be used in calls
like X509_set_pubkey.

    my $key = Net::SSLeay::EVP_PKEY_new();
    my $ec  = Net::SSLeay::EC_KEY_generate_key($curve);
    Net::SSLeay::EVP_PKEY_assign_EC_KEY($key,$ec);

    # $curve - curve name like 'secp521r1' or the matching Id (integer) of the curve
    #
    # returns: value corresponding to openssl's EC_KEY structure (0 on failure)

This function has no equivalent in OpenSSL but combines multiple OpenSSL
functions for an easier interface.

=item * CTX_set_ecdh_auto, set_ecdh_auto

These functions enable or disable the automatic curve selection on the server
side by calling SSL_CTX_set_ecdh_auto or SSL_set_ecdh_auto respectively.
If enabled the highest preference curve is automatically used for ECDH temporary
keys used during key exchange.
This function is no longer available for OpenSSL 1.1.0 or higher.

    Net::SSLeay::CTX_set_ecdh_auto($ctx,1);
    Net::SSLeay::set_ecdh_auto($ssl,1);

=item * CTX_set1_curves_list, set1_curves_list

These functions set the supported curves (in order of preference) by calling
SSL_CTX_set1_curves_list or SSL_set1_curves_list respectively.
For a TLS client these curves are offered to the server in the supported curves
extension while on the server side these are used to determine the shared
curve.
These functions are only available since OpenSSL 1.1.0.

    Net::SSLeay::CTX_set1_curves_list($ctx,"P-521:P-384:P-256");
    Net::SSLeay::set1_curves_list($ssl,"P-521:P-384:P-256");

=item * CTX_set1_groups_list, set1_groups_list

These functions set the supported groups (in order of preference) by calling
SSL_CTX_set1_groups_list or SSL_set1_groups_list respectively.
This is practically the same as CTX_set1_curves_list and set1_curves_list except
that all DH groups can be given as supported by TLS 1.3.
These functions are only available since OpenSSL 1.1.1.

    Net::SSLeay::CTX_set1_groups_list($ctx,"P-521:P-384:P-256");
    Net::SSLeay::set1_groups_list($ssl,"P-521:P-384:P-256");

=back

=head3 Low level API: OSSL_LIB_CTX and OSSL_PROVIDER related functions

=over

=item * OSSL_LIB_CTX_get0_global_default

Returns a concrete (non NULL) reference to the global default library context.

    my $libctx = Net::SSLeay::OSSL_LIB_CTX_get0_global_default();
    # returns: a value corresponding to OSSL_LIB_CTX structure or false on failure

Typically it's simpler to use undef with functions that take an
OSSL_LIB_CTX argument when global default library context is needed.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OSSL_LIB_CTX_get0_global_default.html>

=item * OSSL_PROVIDER_load

Loads and initializes a provider

    my $provider = Net::SSLeay::OSSL_PROVIDER_load($libctx, $name);
    # $libctx - value corresponding to OSSL_LIB_CTX structure or undef
    # $name - (string) provider name, e.g., 'legacy'
    #
    # returns: a value corresponding to OSSL_PROVIDER or false on failure

Using undef loads the provider within the global default library context.

    my $provider = Net::SSLeay::OSSL_PROVIDER_load(undef, 'legacy');

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OSSL_PROVIDER_load.html>

=item * OSSL_PROVIDER_try_load

Loads and initializes a provider similar to OSSL_PROVIDER_load with additional fallback control.

    my $provider = Net::SSLeay::OSSL_PROVIDER_try_load($libctx, $name, $retain_fallbacks);
    # $libctx - value corresponding to OSSL_LIB_CTX structure or undef
    # $name - (string) provider name, e.g., 'legacy'
    # $retain_fallbacks - (integer) 0 or 1
    #
    # returns: a value corresponding to OSSL_PROVIDER or false on failure

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OSSL_PROVIDER_try_load.html>

=item * OSSL_PROVIDER_unload

Unloads the given provider.

    my $rv = Net::SSLeay::OSSL_PROVIDER_unload($provider);
    # $provider - a value corresponding to OSSL_PROVIDER
    #
    # returns: (integer) 1 on success, 0 on error

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OSSL_PROVIDER_unload.html>

=item * OSSL_PROVIDER_available

Checks if a named provider is available for use.

    my $rv = Net::SSLeay::OSSL_PROVIDER_available($libctx, $name);
    # $libctx - value corresponding to OSSL_LIB_CTX structure or undef
    # $name - (string) provider name, e.g., 'legacy'
    #
    # returns: (integer) 1 if the named provider is available, otherwise 0.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OSSL_PROVIDER_available.html>

=item * OSSL_PROVIDER_do_all

Iterates over all loaded providers. A callback is called for each provider.

    my $rv = Net::SSLeay::OSSL_PROVIDER_do_all($libctx, $cb, $cbdata);
    # $libctx - value corresponding to OSSL_LIB_CTX structure or undef
    # $cb - reference to a perl callback function
    # $cbdata - data that will be passed to callback function
    #
    # returns: (integer) 1 if all callbacks returned 1, 0 the first time a callback returns 0.

Example:

    sub do_all_cb {
        my ($provider, $cbdata) = @_;

        my $name = Net::SSLeay::OSSL_PROVIDER_get0_name($provider);
        print "Callback for provider: '$name', cbdata: '$cbdata'\n";
        return 1;
    }
    my $data_for_cb = 'Hello';

    # Triggers default provider automatic loading.
    Net::SSLeay::OSSL_PROVIDER_available(undef, 'default') || die 'default provider not available';
    Net::SSLeay::OSSL_PROVIDER_load(undef, 'legacy') || die 'load legacy';
    Net::SSLeay::OSSL_PROVIDER_load(undef, 'null')   || die 'load null';
    Net::SSLeay::OSSL_PROVIDER_do_all(undef, \&do_all_cb, $data_for_cb) || die 'a callback failed';

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OSSL_PROVIDER_do_all.html>

=item * OSSL_PROVIDER_get0_name

Returns the name of the given provider.

    my $name = Net::SSLeay::OSSL_PROVIDER_get0_name($provider);
    # $provider - a value corresponding to OSSL_PROVIDER
    #
    # returns: (string) provider name, e.g., 'legacy'

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OSSL_PROVIDER_get0_name.html>

=item * OSSL_PROVIDER_self_test

Runs the provider's self tests.

    my $rv = Net::SSLeay::OSSL_PROVIDER_self_test($provider);
    # $libctx - value corresponding to OSSL_LIB_CTX structure or undef
    # $provider - a value corresponding to OSSL_PROVIDER
    #
    # returns: (integer) returns 1 if the self tests pass, 0 on error

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/OSSL_PROVIDER_self_test.html>

=back

=head3 Low level API: TLS PSK related functions

B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and before.  The TLSv1.3 specific functions require at least OpenSSL 1.1.1 and the others require at least OpenSSL 1.0.0. Not available in LibreSSL.

=over

=item * CTX_use_psk_identity_hint

Set PSK identity hint for SSL_CTX on TLS server for TLSv1.2 and earlier versions.

    my $ret = Net::SSLeay::CTX_use_psk_identity_hint($ctx, $hint);
    # $ctx - value corresponding to OpenSSL SSL_CTX structure
    # $hint - string, a hint sent to the TLS clients
    #
    # returns: 1 on success, 0 on failure

Example:

    my $ret = Net::SSLeay::CTX_use_psk_identity_hint($ctx, 'ctx server identity_hint');

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_use_psk_identity_hint.html>

=item * use_psk_identity_hint

Set PSK identity hint for SSL on TLS server for TLSv1.2 and earlier versions.

    my $ret = Net::SSLeay::use_psk_identity_hint($ssl, $hint);
    # $ssl - value corresponding to OpenSSL SSL structure
    # $hint - string, a hint sent to the TLS clients
    #
    # returns: 1 on success, 0 on failure

Example:

    my $ret = Net::SSLeay::use_psk_identity_hint($ssl, 'ssl server identity_hint');

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_use_psk_identity_hint.html>

=item * CTX_set_psk_server_callback

Set a callback for an SSL_CTX on TLS server for using PSKs with all TLS versions.

B<NOTE:> With TLSv1.3 Net::SSLeay::CTX_set_psk_find_session_callback
or Net::SSLeay::set_psk_find_session_callback is recommended.

    # First set up a callback function.
    sub tls12_psk_cb {
        my ($ssl, $identity, $max_psk_len) = @_;

        # Note: $identity is potentially hostile user supplied data

        my $psk = pack('H*', 'deadbeef');
        return $psk if length $psk <= $max_psk_len;

        return undef;
    }

    my $cb = \&tls12_psk_cb;
    Net::SSLeay::CTX_set_psk_server_callback($ctx, $cb);
    # $ctx - value corresponding to OpenSSL SSL_CTX structure
    # $cb - reference to callback function
    #
    # returns: no return value

The callback function must return a PSK in packed binary format, or
C<undef> to trigger C<unknown_psk_identity> alert and TLS handshake
failure. If TLS handshake failure without PSK specific alert is
required, return packed random data.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_psk_server_callback.html>

=item * set_psk_server_callback

Set a callback for an SSL on TLS server for using PSKs with all TLS versions.

B<NOTE:> With TLSv1.3 Net::SSLeay::CTX_set_psk_find_session_callback
or Net::SSLeay::set_psk_find_session_callback is recommended.

    Net::SSLeay::set_psk_server_callback($ssl, $cb);
    # $ssl - value corresponding to OpenSSL SSL structure
    # $cb - reference to callback function
    #
    # returns: no return value

See Net::SSLeay::CTX_set_psk_server_callback() documentation for
a full example with a callback.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_psk_server_callback.html>

=item * CTX_set_psk_find_session_callback

Set a callback for an SSL_CTX on TLS server for using TLSv1.3 PSKs.

    # First set up a callback function.
    sub tls13_psk_cb {
        my ($ssl, $identity) = @_;

        # Note: $identity is potentially hostile user supplied data

        my $sess = Net::SSLeay::SESSION_new();
        my $cipher = Net::SSLeay::CIPHER_find($ssl, pack('n', 0x1301));
        Net::SSLeay::SESSION_set1_master_key($sess, pack('H*', 'deadbeef'));
        Net::SSLeay::SESSION_set_cipher($sess, $cipher);
        Net::SSLeay::SESSION_set_protocol_version($sess, Net::SSLeay::version($ssl));

        return (1, $sess);
    }

    my $cb = \&tls13_psk_cb;
    Net::SSLeay::CTX_set_psk_find_session_callback($ctx, $cb);
    # $ctx - value corresponding to OpenSSL SSL_CTX structure
    # $cb - reference to callback function
    #
    # returns: no return value

The callback function must return a two value list. When the first
value is 0, the connection setup fails. When the first value is 1, the
second value must be a valid C<SSL_SESSION> or C<undef>. When the
second value is a valid C<SSL_SESSION>, the TLS handshake proceeds
with PSK authentication. When the the second value is C<undef>, PSK is
not used the TLS handshake proceeds with certificate authentication.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_psk_find_session_callback.html>

=item * set_psk_find_session_callback

Set a callback for an SSL on TLS server for using TLSv1.3 PSKs.

    Net::SSLeay::set_psk_find_session_callback($ssl, $cb);
    # $ssl - value corresponding to OpenSSL SSL structure
    # $cb - reference to callback function
    #
    # returns: no return value

See Net::SSLeay::CTX_set_psk_find_session_callback() documentation for
a full example with a callback.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_set_psk_find_session_callback.html>

=item * CTX_set_psk_use_session_callback

Set a callback for an SSL_CTX on TLS client for using TLSv1.3 PSKs.

    # First set up a callback function.
    sub tls13_use_psk_cb {
        my ($ssl, $md) = @_;

        my $psk_identity = "test-tls-psk";
        my $sess = Net::SSLeay::SESSION_new();
        my $cipher = Net::SSLeay::CIPHER_find($ssl, pack('n', 0x1301));
        Net::SSLeay::SESSION_set1_master_key($sess, pack('H*', 'deadbeef'));
        Net::SSLeay::SESSION_set_cipher($sess, $cipher);
        Net::SSLeay::SESSION_set_protocol_version($sess, Net::SSLeay::TLS1_3_VERSION());

        # Typically not defined, see OpenSSL manual
        if ($md) {
            my $sess_md = Net::SSLeay::CIPHER_get_handshake_digest($cipher);
            my $md_type; $md_type = Net::SSLeay::EVP_MD_type($md) if $md;
            my $sess_md_type = Net::SSLeay::EVP_MD_type($sess_md);

            if ($md_type != $sess_md_type) {
                # Example only: guess and try SHA384
                my $switched_cipher = Net::SSLeay::CIPHER_find($ssl, pack('n', 0x1302));
                my $switched_md = Net::SSLeay::CIPHER_get_handshake_digest($switched_cipher);
                my $switched_md_type = Net::SSLeay::EVP_MD_type($switched_md);
                if ($md_type != $switched_md_type) {
                    # Guessed wrong, can't proceed with mismatched digest function
                    Net::SSLeay::SESSION_free($sess);
                    return (0, undef, undef);
                }
                Net::SSLeay::SESSION_set_cipher($sess, $switched_cipher);
            }
        }

        return (1, $psk_identity, $sess);
    }

    my $cb = \&tls13_use_psk_cb;
    Net::SSLeay::CTX_set_psk_use_session_callback($ctx, $cb);
    # $ctx - value corresponding to OpenSSL SSL_CTX structure
    # $cb - reference to callback function
    #
    # returns: no return value

The callback function must return a two value list. When the first
value is 0, the connection setup fails. When the first value is 1, the
second value must be a valid C<SSL_SESSION> or C<undef>. When the
second value is a valid C<SSL_SESSION>, the TLS handshake proceeds
with PSK authentication. When the the second value is C<undef>, PSK is
not used the TLS handshake proceeds with certificate authentication.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_psk_find_session_callback.html>

=item * set_psk_use_session_callback

Set a callback for an SSL on TLS client for using TLSv1.3 PSKs.

    # First set up a callback function.
    sub tls13_psk_cb {
        my ($ssl, $identity) = @_;

        # Note: $identity is potentially hostile user supplied data

        my $sess = Net::SSLeay::SESSION_new();
        my $cipher = Net::SSLeay::CIPHER_find($ssl, pack('n', 0x1301));
        Net::SSLeay::SESSION_set1_master_key($sess, pack('H*', 'deadbeef'));
        Net::SSLeay::SESSION_set_cipher($sess, $cipher);
        Net::SSLeay::SESSION_set_protocol_version($sess, Net::SSLeay::version($ssl));

        return (1, $sess);
    }

    my $cb = \&tls13_psk_cb;
    Net::SSLeay::CTX_set_psk_find_session_callback($ctx, $cb);
    # $ctx - value corresponding to OpenSSL SSL_CTX structure
    # $cb - reference to callback function
    #
    # returns: no return value

The callback function must return a two value list. When the first
value is 0, the connection setup fails. When the first value is 1, the
second value must be a valid C<SSL_SESSION> or C<undef>. When the
second value is a valid C<SSL_SESSION>, the TLS handshake proceeds
with PSK authentication. When the the second value is C<undef>, PSK is
not used the TLS handshake proceeds with certificate authentication.

Check openssl doc L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_psk_find_session_callback.html>

=back

=head2 Constants

There are many openssl constants available in L<Net::SSLeay>. You can use them like this:

    use Net::SSLeay;
    print &Net::SSLeay::NID_commonName;
    # or
    print Net::SSLeay::NID_commonName();

Or you can import them and use:

    use Net::SSLeay qw/NID_commonName/;
    print &NID_commonName;
    # or
    print NID_commonName();
    # or
    print NID_commonName;

The constants names are derived from openssl constants, however constants starting with C<SSL_> prefix
have name with C<SSL_> part stripped - e.g. openssl's constant C<SSL_OP_ALL> is available as C<Net::SSLeay::OP_ALL>

The list of all available constant names:

=for comment

The list below is automatically generated - do not manually modify it.
To add or remove a constant, edit helper_script/constants.txt, then run
helper_script/update-exported-constants.

=for start_constants

    AD_ACCESS_DENIED                        OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
    AD_BAD_CERTIFICATE                      OP_CIPHER_SERVER_PREFERENCE
    AD_BAD_CERTIFICATE_HASH_VALUE           OP_CISCO_ANYCONNECT
    AD_BAD_CERTIFICATE_STATUS_RESPONSE      OP_CLEANSE_PLAINTEXT
    AD_BAD_RECORD_MAC                       OP_COOKIE_EXCHANGE
    AD_CERTIFICATE_EXPIRED                  OP_CRYPTOPRO_TLSEXT_BUG
    AD_CERTIFICATE_REQUIRED                 OP_DISABLE_TLSEXT_CA_NAMES
    AD_CERTIFICATE_REVOKED                  OP_DONT_INSERT_EMPTY_FRAGMENTS
    AD_CERTIFICATE_UNKNOWN                  OP_ENABLE_KTLS
    AD_CERTIFICATE_UNOBTAINABLE             OP_ENABLE_MIDDLEBOX_COMPAT
    AD_CLOSE_NOTIFY                         OP_EPHEMERAL_RSA
    AD_DECODE_ERROR                         OP_IGNORE_UNEXPECTED_EOF
    AD_DECOMPRESSION_FAILURE                OP_LEGACY_SERVER_CONNECT
    AD_DECRYPTION_FAILED                    OP_MICROSOFT_BIG_SSLV3_BUFFER
    AD_DECRYPT_ERROR                        OP_MICROSOFT_SESS_ID_BUG
    AD_EXPORT_RESTRICTION                   OP_MSIE_SSLV2_RSA_PADDING
    AD_HANDSHAKE_FAILURE                    OP_NETSCAPE_CA_DN_BUG
    AD_ILLEGAL_PARAMETER                    OP_NETSCAPE_CHALLENGE_BUG
    AD_INAPPROPRIATE_FALLBACK               OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
    AD_INSUFFICIENT_SECURITY                OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
    AD_INTERNAL_ERROR                       OP_NON_EXPORT_FIRST
    AD_MISSING_EXTENSION                    OP_NO_ANTI_REPLAY
    AD_NO_APPLICATION_PROTOCOL              OP_NO_CLIENT_RENEGOTIATION
    AD_NO_CERTIFICATE                       OP_NO_COMPRESSION
    AD_NO_RENEGOTIATION                     OP_NO_ENCRYPT_THEN_MAC
    AD_PROTOCOL_VERSION                     OP_NO_EXTENDED_MASTER_SECRET
    AD_RECORD_OVERFLOW                      OP_NO_QUERY_MTU
    AD_UNEXPECTED_MESSAGE                   OP_NO_RENEGOTIATION
    AD_UNKNOWN_CA                           OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
    AD_UNKNOWN_PSK_IDENTITY                 OP_NO_SSL_MASK
    AD_UNRECOGNIZED_NAME                    OP_NO_SSLv2
    AD_UNSUPPORTED_CERTIFICATE              OP_NO_SSLv3
    AD_UNSUPPORTED_EXTENSION                OP_NO_TICKET
    AD_USER_CANCELLED                       OP_NO_TLSv1
    ASN1_STRFLGS_ESC_CTRL                   OP_NO_TLSv1_1
    ASN1_STRFLGS_ESC_MSB                    OP_NO_TLSv1_2
    ASN1_STRFLGS_ESC_QUOTE                  OP_NO_TLSv1_3
    ASN1_STRFLGS_RFC2253                    OP_PKCS1_CHECK_1
    ASYNC_NO_JOBS                           OP_PKCS1_CHECK_2
    ASYNC_PAUSED                            OP_PRIORITIZE_CHACHA
    CB_ACCEPT_EXIT                          OP_SAFARI_ECDHE_ECDSA_BUG
    CB_ACCEPT_LOOP                          OP_SINGLE_DH_USE
    CB_ALERT                                OP_SINGLE_ECDH_USE
    CB_CONNECT_EXIT                         OP_SSLEAY_080_CLIENT_DH_BUG
    CB_CONNECT_LOOP                         OP_SSLREF2_REUSE_CERT_TYPE_BUG
    CB_EXIT                                 OP_TLSEXT_PADDING
    CB_HANDSHAKE_DONE                       OP_TLS_BLOCK_PADDING_BUG
    CB_HANDSHAKE_START                      OP_TLS_D5_BUG
    CB_LOOP                                 OP_TLS_ROLLBACK_BUG
    CB_READ                                 READING
    CB_READ_ALERT                           RECEIVED_SHUTDOWN
    CB_WRITE                                RETRY_VERIFY
    CB_WRITE_ALERT                          RSA_3
    CLIENT_HELLO_CB                         RSA_F4
    CLIENT_HELLO_ERROR                      R_BAD_AUTHENTICATION_TYPE
    CLIENT_HELLO_RETRY                      R_BAD_CHECKSUM
    CLIENT_HELLO_SUCCESS                    R_BAD_MAC_DECODE
    ERROR_NONE                              R_BAD_RESPONSE_ARGUMENT
    ERROR_SSL                               R_BAD_SSL_FILETYPE
    ERROR_SYSCALL                           R_BAD_SSL_SESSION_ID_LENGTH
    ERROR_WANT_ACCEPT                       R_BAD_STATE
    ERROR_WANT_ASYNC                        R_BAD_WRITE_RETRY
    ERROR_WANT_ASYNC_JOB                    R_CHALLENGE_IS_DIFFERENT
    ERROR_WANT_CLIENT_HELLO_CB              R_CIPHER_TABLE_SRC_ERROR
    ERROR_WANT_CONNECT                      R_INVALID_CHALLENGE_LENGTH
    ERROR_WANT_READ                         R_NO_CERTIFICATE_SET
    ERROR_WANT_RETRY_VERIFY                 R_NO_CERTIFICATE_SPECIFIED
    ERROR_WANT_WRITE                        R_NO_CIPHER_LIST
    ERROR_WANT_X509_LOOKUP                  R_NO_CIPHER_MATCH
    ERROR_ZERO_RETURN                       R_NO_PRIVATEKEY
    EVP_PKS_DSA                             R_NO_PUBLICKEY
    EVP_PKS_EC                              R_NULL_SSL_CTX
    EVP_PKS_RSA                             R_PEER_DID_NOT_RETURN_A_CERTIFICATE
    EVP_PKT_ENC                             R_PEER_ERROR
    EVP_PKT_EXCH                            R_PEER_ERROR_CERTIFICATE
    EVP_PKT_EXP                             R_PEER_ERROR_NO_CIPHER
    EVP_PKT_SIGN                            R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE
    EVP_PK_DH                               R_PUBLIC_KEY_ENCRYPT_ERROR
    EVP_PK_DSA                              R_PUBLIC_KEY_IS_NOT_RSA
    EVP_PK_EC                               R_READ_WRONG_PACKET_TYPE
    EVP_PK_RSA                              R_SHORT_READ
    FILETYPE_ASN1                           R_SSL_SESSION_ID_IS_DIFFERENT
    FILETYPE_PEM                            R_UNABLE_TO_EXTRACT_PUBLIC_KEY
    F_CLIENT_CERTIFICATE                    R_UNKNOWN_REMOTE_ERROR_TYPE
    F_CLIENT_HELLO                          R_UNKNOWN_STATE
    F_CLIENT_MASTER_KEY                     R_X509_LIB
    F_D2I_SSL_SESSION                       SENT_SHUTDOWN
    F_GET_CLIENT_FINISHED                   SESSION_ASN1_VERSION
    F_GET_CLIENT_HELLO                      SESS_CACHE_BOTH
    F_GET_CLIENT_MASTER_KEY                 SESS_CACHE_CLIENT
    F_GET_SERVER_FINISHED                   SESS_CACHE_NO_AUTO_CLEAR
    F_GET_SERVER_HELLO                      SESS_CACHE_NO_INTERNAL
    F_GET_SERVER_VERIFY                     SESS_CACHE_NO_INTERNAL_LOOKUP
    F_I2D_SSL_SESSION                       SESS_CACHE_NO_INTERNAL_STORE
    F_READ_N                                SESS_CACHE_OFF
    F_REQUEST_CERTIFICATE                   SESS_CACHE_SERVER
    F_SERVER_HELLO                          SESS_CACHE_UPDATE_TIME
    F_SSL_CERT_NEW                          SSL2_MT_CLIENT_CERTIFICATE
    F_SSL_GET_NEW_SESSION                   SSL2_MT_CLIENT_FINISHED
    F_SSL_NEW                               SSL2_MT_CLIENT_HELLO
    F_SSL_READ                              SSL2_MT_CLIENT_MASTER_KEY
    F_SSL_RSA_PRIVATE_DECRYPT               SSL2_MT_ERROR
    F_SSL_RSA_PUBLIC_ENCRYPT                SSL2_MT_REQUEST_CERTIFICATE
    F_SSL_SESSION_NEW                       SSL2_MT_SERVER_FINISHED
    F_SSL_SESSION_PRINT_FP                  SSL2_MT_SERVER_HELLO
    F_SSL_SET_FD                            SSL2_MT_SERVER_VERIFY
    F_SSL_SET_RFD                           SSL2_VERSION
    F_SSL_SET_WFD                           SSL3_MT_CCS
    F_SSL_USE_CERTIFICATE                   SSL3_MT_CERTIFICATE
    F_SSL_USE_CERTIFICATE_ASN1              SSL3_MT_CERTIFICATE_REQUEST
    F_SSL_USE_CERTIFICATE_FILE              SSL3_MT_CERTIFICATE_STATUS
    F_SSL_USE_PRIVATEKEY                    SSL3_MT_CERTIFICATE_URL
    F_SSL_USE_PRIVATEKEY_ASN1               SSL3_MT_CERTIFICATE_VERIFY
    F_SSL_USE_PRIVATEKEY_FILE               SSL3_MT_CHANGE_CIPHER_SPEC
    F_SSL_USE_RSAPRIVATEKEY                 SSL3_MT_CLIENT_HELLO
    F_SSL_USE_RSAPRIVATEKEY_ASN1            SSL3_MT_CLIENT_KEY_EXCHANGE
    F_SSL_USE_RSAPRIVATEKEY_FILE            SSL3_MT_ENCRYPTED_EXTENSIONS
    F_WRITE_PENDING                         SSL3_MT_END_OF_EARLY_DATA
    GEN_DIRNAME                             SSL3_MT_FINISHED
    GEN_DNS                                 SSL3_MT_HELLO_REQUEST
    GEN_EDIPARTY                            SSL3_MT_KEY_UPDATE
    GEN_EMAIL                               SSL3_MT_MESSAGE_HASH
    GEN_IPADD                               SSL3_MT_NEWSESSION_TICKET
    GEN_OTHERNAME                           SSL3_MT_NEXT_PROTO
    GEN_RID                                 SSL3_MT_SERVER_DONE
    GEN_URI                                 SSL3_MT_SERVER_HELLO
    GEN_X400                                SSL3_MT_SERVER_KEY_EXCHANGE
    LIBRESSL_VERSION_NUMBER                 SSL3_MT_SUPPLEMENTAL_DATA
    MBSTRING_ASC                            SSL3_RT_ALERT
    MBSTRING_BMP                            SSL3_RT_APPLICATION_DATA
    MBSTRING_FLAG                           SSL3_RT_CHANGE_CIPHER_SPEC
    MBSTRING_UNIV                           SSL3_RT_HANDSHAKE
    MBSTRING_UTF8                           SSL3_RT_HEADER
    MIN_RSA_MODULUS_LENGTH_IN_BYTES         SSL3_RT_INNER_CONTENT_TYPE
    MODE_ACCEPT_MOVING_WRITE_BUFFER         SSL3_VERSION
    MODE_ASYNC                              SSLEAY_BUILT_ON
    MODE_AUTO_RETRY                         SSLEAY_CFLAGS
    MODE_ENABLE_PARTIAL_WRITE               SSLEAY_DIR
    MODE_NO_AUTO_CHAIN                      SSLEAY_PLATFORM
    MODE_RELEASE_BUFFERS                    SSLEAY_VERSION
    NID_OCSP_sign                           ST_ACCEPT
    NID_SMIMECapabilities                   ST_BEFORE
    NID_X500                                ST_CONNECT
    NID_X509                                ST_INIT
    NID_ad_OCSP                             ST_OK
    NID_ad_ca_issuers                       ST_READ_BODY
    NID_algorithm                           ST_READ_HEADER
    NID_authority_key_identifier            TLS1_1_VERSION
    NID_basic_constraints                   TLS1_2_VERSION
    NID_bf_cbc                              TLS1_3_VERSION
    NID_bf_cfb64                            TLS1_VERSION
    NID_bf_ecb                              TLSEXT_STATUSTYPE_ocsp
    NID_bf_ofb64                            TLSEXT_TYPE_application_layer_protocol_negotiation
    NID_cast5_cbc                           TLSEXT_TYPE_cert_type
    NID_cast5_cfb64                         TLSEXT_TYPE_certificate_authorities
    NID_cast5_ecb                           TLSEXT_TYPE_client_authz
    NID_cast5_ofb64                         TLSEXT_TYPE_client_cert_type
    NID_certBag                             TLSEXT_TYPE_client_certificate_url
    NID_certificate_policies                TLSEXT_TYPE_compress_certificate
    NID_client_auth                         TLSEXT_TYPE_cookie
    NID_code_sign                           TLSEXT_TYPE_early_data
    NID_commonName                          TLSEXT_TYPE_ec_point_formats
    NID_countryName                         TLSEXT_TYPE_elliptic_curves
    NID_crlBag                              TLSEXT_TYPE_encrypt_then_mac
    NID_crl_distribution_points             TLSEXT_TYPE_extended_master_secret
    NID_crl_number                          TLSEXT_TYPE_key_share
    NID_crl_reason                          TLSEXT_TYPE_max_fragment_length
    NID_delta_crl                           TLSEXT_TYPE_next_proto_neg
    NID_des_cbc                             TLSEXT_TYPE_padding
    NID_des_cfb64                           TLSEXT_TYPE_post_handshake_auth
    NID_des_ecb                             TLSEXT_TYPE_psk
    NID_des_ede                             TLSEXT_TYPE_psk_kex_modes
    NID_des_ede3                            TLSEXT_TYPE_quic_transport_parameters
    NID_des_ede3_cbc                        TLSEXT_TYPE_renegotiate
    NID_des_ede3_cfb64                      TLSEXT_TYPE_server_authz
    NID_des_ede3_ofb64                      TLSEXT_TYPE_server_cert_type
    NID_des_ede_cbc                         TLSEXT_TYPE_server_name
    NID_des_ede_cfb64                       TLSEXT_TYPE_session_ticket
    NID_des_ede_ofb64                       TLSEXT_TYPE_signature_algorithms
    NID_des_ofb64                           TLSEXT_TYPE_signature_algorithms_cert
    NID_description                         TLSEXT_TYPE_signed_certificate_timestamp
    NID_desx_cbc                            TLSEXT_TYPE_srp
    NID_dhKeyAgreement                      TLSEXT_TYPE_status_request
    NID_dnQualifier                         TLSEXT_TYPE_supported_groups
    NID_dsa                                 TLSEXT_TYPE_supported_versions
    NID_dsaWithSHA                          TLSEXT_TYPE_truncated_hmac
    NID_dsaWithSHA1                         TLSEXT_TYPE_trusted_ca_keys
    NID_dsaWithSHA1_2                       TLSEXT_TYPE_use_srtp
    NID_dsa_2                               TLSEXT_TYPE_user_mapping
    NID_email_protect                       VERIFY_CLIENT_ONCE
    NID_ext_key_usage                       VERIFY_FAIL_IF_NO_PEER_CERT
    NID_ext_req                             VERIFY_NONE
    NID_friendlyName                        VERIFY_PEER
    NID_givenName                           VERIFY_POST_HANDSHAKE
    NID_hmacWithSHA1                        V_OCSP_CERTSTATUS_GOOD
    NID_id_ad                               V_OCSP_CERTSTATUS_REVOKED
    NID_id_ce                               V_OCSP_CERTSTATUS_UNKNOWN
    NID_id_kp                               WRITING
    NID_id_pbkdf2                           X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
    NID_id_pe                               X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS
    NID_id_pkix                             X509_CHECK_FLAG_NEVER_CHECK_SUBJECT
    NID_id_qt_cps                           X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
    NID_id_qt_unotice                       X509_CHECK_FLAG_NO_WILDCARDS
    NID_idea_cbc                            X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
    NID_idea_cfb64                          X509_CRL_VERSION_1
    NID_idea_ecb                            X509_CRL_VERSION_2
    NID_idea_ofb64                          X509_FILETYPE_ASN1
    NID_info_access                         X509_FILETYPE_DEFAULT
    NID_initials                            X509_FILETYPE_PEM
    NID_invalidity_date                     X509_LOOKUP
    NID_issuer_alt_name                     X509_PURPOSE_ANY
    NID_keyBag                              X509_PURPOSE_CRL_SIGN
    NID_key_usage                           X509_PURPOSE_NS_SSL_SERVER
    NID_localKeyID                          X509_PURPOSE_OCSP_HELPER
    NID_localityName                        X509_PURPOSE_SMIME_ENCRYPT
    NID_md2                                 X509_PURPOSE_SMIME_SIGN
    NID_md2WithRSAEncryption                X509_PURPOSE_SSL_CLIENT
    NID_md5                                 X509_PURPOSE_SSL_SERVER
    NID_md5WithRSA                          X509_PURPOSE_TIMESTAMP_SIGN
    NID_md5WithRSAEncryption                X509_REQ_VERSION_1
    NID_md5_sha1                            X509_REQ_VERSION_2
    NID_mdc2                                X509_REQ_VERSION_3
    NID_mdc2WithRSA                         X509_TRUST_COMPAT
    NID_ms_code_com                         X509_TRUST_DEFAULT
    NID_ms_code_ind                         X509_TRUST_EMAIL
    NID_ms_ctl_sign                         X509_TRUST_OBJECT_SIGN
    NID_ms_efs                              X509_TRUST_OCSP_REQUEST
    NID_ms_ext_req                          X509_TRUST_OCSP_SIGN
    NID_ms_sgc                              X509_TRUST_SSL_CLIENT
    NID_name                                X509_TRUST_SSL_SERVER
    NID_netscape                            X509_TRUST_TSA
    NID_netscape_base_url                   X509_VERSION_1
    NID_netscape_ca_policy_url              X509_VERSION_2
    NID_netscape_ca_revocation_url          X509_VERSION_3
    NID_netscape_cert_extension             X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH
    NID_netscape_cert_sequence              X509_V_ERR_AKID_SKID_MISMATCH
    NID_netscape_cert_type                  X509_V_ERR_APPLICATION_VERIFICATION
    NID_netscape_comment                    X509_V_ERR_AUTHORITY_KEY_IDENTIFIER_CRITICAL
    NID_netscape_data_type                  X509_V_ERR_CA_BCONS_NOT_CRITICAL
    NID_netscape_renewal_url                X509_V_ERR_CA_CERT_MISSING_KEY_USAGE
    NID_netscape_revocation_url             X509_V_ERR_CA_KEY_TOO_SMALL
    NID_netscape_ssl_server_name            X509_V_ERR_CA_MD_TOO_WEAK
    NID_ns_sgc                              X509_V_ERR_CERT_CHAIN_TOO_LONG
    NID_organizationName                    X509_V_ERR_CERT_HAS_EXPIRED
    NID_organizationalUnitName              X509_V_ERR_CERT_NOT_YET_VALID
    NID_pbeWithMD2AndDES_CBC                X509_V_ERR_CERT_REJECTED
    NID_pbeWithMD2AndRC2_CBC                X509_V_ERR_CERT_REVOKED
    NID_pbeWithMD5AndCast5_CBC              X509_V_ERR_CERT_SIGNATURE_FAILURE
    NID_pbeWithMD5AndDES_CBC                X509_V_ERR_CERT_UNTRUSTED
    NID_pbeWithMD5AndRC2_CBC                X509_V_ERR_CRL_HAS_EXPIRED
    NID_pbeWithSHA1AndDES_CBC               X509_V_ERR_CRL_NOT_YET_VALID
    NID_pbeWithSHA1AndRC2_CBC               X509_V_ERR_CRL_PATH_VALIDATION_ERROR
    NID_pbe_WithSHA1And128BitRC2_CBC        X509_V_ERR_CRL_SIGNATURE_FAILURE
    NID_pbe_WithSHA1And128BitRC4            X509_V_ERR_DANE_NO_MATCH
    NID_pbe_WithSHA1And2_Key_TripleDES_CBC  X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
    NID_pbe_WithSHA1And3_Key_TripleDES_CBC  X509_V_ERR_DIFFERENT_CRL_SCOPE
    NID_pbe_WithSHA1And40BitRC2_CBC         X509_V_ERR_EC_KEY_EXPLICIT_PARAMS
    NID_pbe_WithSHA1And40BitRC4             X509_V_ERR_EE_KEY_TOO_SMALL
    NID_pbes2                               X509_V_ERR_EMAIL_MISMATCH
    NID_pbmac1                              X509_V_ERR_EMPTY_SUBJECT_ALT_NAME
    NID_pkcs                                X509_V_ERR_EMPTY_SUBJECT_SAN_NOT_CRITICAL
    NID_pkcs3                               X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
    NID_pkcs7                               X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
    NID_pkcs7_data                          X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
    NID_pkcs7_digest                        X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
    NID_pkcs7_encrypted                     X509_V_ERR_EXCLUDED_VIOLATION
    NID_pkcs7_enveloped                     X509_V_ERR_EXTENSIONS_REQUIRE_VERSION_3
    NID_pkcs7_signed                        X509_V_ERR_HOSTNAME_MISMATCH
    NID_pkcs7_signedAndEnveloped            X509_V_ERR_INVALID_CA
    NID_pkcs8ShroudedKeyBag                 X509_V_ERR_INVALID_CALL
    NID_pkcs9                               X509_V_ERR_INVALID_EXTENSION
    NID_pkcs9_challengePassword             X509_V_ERR_INVALID_NON_CA
    NID_pkcs9_contentType                   X509_V_ERR_INVALID_POLICY_EXTENSION
    NID_pkcs9_countersignature              X509_V_ERR_INVALID_PURPOSE
    NID_pkcs9_emailAddress                  X509_V_ERR_IP_ADDRESS_MISMATCH
    NID_pkcs9_extCertAttributes             X509_V_ERR_ISSUER_NAME_EMPTY
    NID_pkcs9_messageDigest                 X509_V_ERR_KEYUSAGE_NO_CERTSIGN
    NID_pkcs9_signingTime                   X509_V_ERR_KEYUSAGE_NO_CRL_SIGN
    NID_pkcs9_unstructuredAddress           X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE
    NID_pkcs9_unstructuredName              X509_V_ERR_KU_KEY_CERT_SIGN_INVALID_FOR_NON_CA
    NID_private_key_usage_period            X509_V_ERR_MISSING_AUTHORITY_KEY_IDENTIFIER
    NID_rc2_40_cbc                          X509_V_ERR_MISSING_SUBJECT_KEY_IDENTIFIER
    NID_rc2_64_cbc                          X509_V_ERR_NO_EXPLICIT_POLICY
    NID_rc2_cbc                             X509_V_ERR_NO_ISSUER_PUBLIC_KEY
    NID_rc2_cfb64                           X509_V_ERR_NO_VALID_SCTS
    NID_rc2_ecb                             X509_V_ERR_OCSP_CERT_UNKNOWN
    NID_rc2_ofb64                           X509_V_ERR_OCSP_VERIFY_FAILED
    NID_rc4                                 X509_V_ERR_OCSP_VERIFY_NEEDED
    NID_rc4_40                              X509_V_ERR_OUT_OF_MEM
    NID_rc5_cbc                             X509_V_ERR_PATHLEN_INVALID_FOR_NON_CA
    NID_rc5_cfb64                           X509_V_ERR_PATHLEN_WITHOUT_KU_KEY_CERT_SIGN
    NID_rc5_ecb                             X509_V_ERR_PATH_LENGTH_EXCEEDED
    NID_rc5_ofb64                           X509_V_ERR_PATH_LOOP
    NID_ripemd160                           X509_V_ERR_PERMITTED_VIOLATION
    NID_ripemd160WithRSA                    X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED
    NID_rle_compression                     X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED
    NID_rsa                                 X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION
    NID_rsaEncryption                       X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
    NID_rsadsi                              X509_V_ERR_SIGNATURE_ALGORITHM_INCONSISTENCY
    NID_safeContentsBag                     X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCH
    NID_sdsiCertificate                     X509_V_ERR_STORE_LOOKUP
    NID_secretBag                           X509_V_ERR_SUBJECT_ISSUER_MISMATCH
    NID_serialNumber                        X509_V_ERR_SUBJECT_KEY_IDENTIFIER_CRITICAL
    NID_server_auth                         X509_V_ERR_SUBJECT_NAME_EMPTY
    NID_sha                                 X509_V_ERR_SUBTREE_MINMAX
    NID_sha1                                X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256
    NID_sha1WithRSA                         X509_V_ERR_SUITE_B_INVALID_ALGORITHM
    NID_sha1WithRSAEncryption               X509_V_ERR_SUITE_B_INVALID_CURVE
    NID_sha224                              X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM
    NID_sha224WithRSAEncryption             X509_V_ERR_SUITE_B_INVALID_VERSION
    NID_sha256                              X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED
    NID_sha256WithRSAEncryption             X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
    NID_sha384                              X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
    NID_sha384WithRSAEncryption             X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
    NID_sha3_224                            X509_V_ERR_UNABLE_TO_GET_CRL
    NID_sha3_256                            X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER
    NID_sha3_384                            X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
    NID_sha3_512                            X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
    NID_sha512                              X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
    NID_sha512WithRSAEncryption             X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION
    NID_sha512_224                          X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION
    NID_sha512_224WithRSAEncryption         X509_V_ERR_UNNESTED_RESOURCE
    NID_sha512_256                          X509_V_ERR_UNSPECIFIED
    NID_sha512_256WithRSAEncryption         X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX
    NID_shaWithRSAEncryption                X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE
    NID_shake128                            X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE
    NID_shake256                            X509_V_ERR_UNSUPPORTED_NAME_SYNTAX
    NID_stateOrProvinceName                 X509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHM
    NID_subject_alt_name                    X509_V_FLAG_ALLOW_PROXY_CERTS
    NID_subject_key_identifier              X509_V_FLAG_CB_ISSUER_CHECK
    NID_surname                             X509_V_FLAG_CHECK_SS_SIGNATURE
    NID_sxnet                               X509_V_FLAG_CRL_CHECK
    NID_time_stamp                          X509_V_FLAG_CRL_CHECK_ALL
    NID_title                               X509_V_FLAG_EXPLICIT_POLICY
    NID_undef                               X509_V_FLAG_EXTENDED_CRL_SUPPORT
    NID_uniqueIdentifier                    X509_V_FLAG_IGNORE_CRITICAL
    NID_x509Certificate                     X509_V_FLAG_INHIBIT_ANY
    NID_x509Crl                             X509_V_FLAG_INHIBIT_MAP
    NID_zlib_compression                    X509_V_FLAG_LEGACY_VERIFY
    NOTHING                                 X509_V_FLAG_NOTIFY_POLICY
    OCSP_RESPONSE_STATUS_INTERNALERROR      X509_V_FLAG_NO_ALT_CHAINS
    OCSP_RESPONSE_STATUS_MALFORMEDREQUEST   X509_V_FLAG_NO_CHECK_TIME
    OCSP_RESPONSE_STATUS_SIGREQUIRED        X509_V_FLAG_PARTIAL_CHAIN
    OCSP_RESPONSE_STATUS_SUCCESSFUL         X509_V_FLAG_POLICY_CHECK
    OCSP_RESPONSE_STATUS_TRYLATER           X509_V_FLAG_POLICY_MASK
    OCSP_RESPONSE_STATUS_UNAUTHORIZED       X509_V_FLAG_SUITEB_128_LOS
    OPENSSL_BUILT_ON                        X509_V_FLAG_SUITEB_128_LOS_ONLY
    OPENSSL_CFLAGS                          X509_V_FLAG_SUITEB_192_LOS
    OPENSSL_CPU_INFO                        X509_V_FLAG_TRUSTED_FIRST
    OPENSSL_DIR                             X509_V_FLAG_USE_CHECK_TIME
    OPENSSL_ENGINES_DIR                     X509_V_FLAG_USE_DELTAS
    OPENSSL_FULL_VERSION_STRING             X509_V_FLAG_X509_STRICT
    OPENSSL_INFO_CONFIG_DIR                 X509_V_OK
    OPENSSL_INFO_CPU_SETTINGS               XN_FLAG_COMPAT
    OPENSSL_INFO_DIR_FILENAME_SEPARATOR     XN_FLAG_DN_REV
    OPENSSL_INFO_DSO_EXTENSION              XN_FLAG_DUMP_UNKNOWN_FIELDS
    OPENSSL_INFO_ENGINES_DIR                XN_FLAG_FN_ALIGN
    OPENSSL_INFO_LIST_SEPARATOR             XN_FLAG_FN_LN
    OPENSSL_INFO_MODULES_DIR                XN_FLAG_FN_MASK
    OPENSSL_INFO_SEED_SOURCE                XN_FLAG_FN_NONE
    OPENSSL_MODULES_DIR                     XN_FLAG_FN_OID
    OPENSSL_PLATFORM                        XN_FLAG_FN_SN
    OPENSSL_VERSION                         XN_FLAG_MULTILINE
    OPENSSL_VERSION_MAJOR                   XN_FLAG_ONELINE
    OPENSSL_VERSION_MINOR                   XN_FLAG_RFC2253
    OPENSSL_VERSION_NUMBER                  XN_FLAG_SEP_COMMA_PLUS
    OPENSSL_VERSION_PATCH                   XN_FLAG_SEP_CPLUS_SPC
    OPENSSL_VERSION_STRING                  XN_FLAG_SEP_MASK
    OP_ALL                                  XN_FLAG_SEP_MULTILINE
    OP_ALLOW_CLIENT_RENEGOTIATION           XN_FLAG_SEP_SPLUS_SPC
    OP_ALLOW_NO_DHE_KEX                     XN_FLAG_SPC_EQ

=for end_constants

=head2 INTERNAL ONLY functions (do not use these)

The following functions are not intended for use from outside of L<Net::SSLeay> module.
They might be removed, renamed or changed without prior notice in future version.

Simply B<DO NOT USE THEM>!

=over

=item * hello

=item * blength

=item * constant

=back

=head1 EXAMPLES

One very good example to look at is the implementation of C<sslcat()> in the
C<SSLeay.pm> file.

The following is a simple SSLeay client (with too little error checking :-(

    #!/usr/bin/perl
    use Socket;
    use Net::SSLeay qw(die_now die_if_ssl_error) ;
    Net::SSLeay::load_error_strings();
    Net::SSLeay::SSLeay_add_ssl_algorithms();
    Net::SSLeay::randomize();

    ($dest_serv, $port, $msg) = @ARGV;      # Read command line
    $port = getservbyname ($port, 'tcp') unless $port =~ /^\d+$/;
    $dest_ip = gethostbyname ($dest_serv);
    $dest_serv_params  = sockaddr_in($port, $dest_ip);

    socket  (S, &AF_INET, &SOCK_STREAM, 0)  or die "socket: $!";
    connect (S, $dest_serv_params)          or die "connect: $!";
    select  (S); $| = 1; select (STDOUT);   # Eliminate STDIO buffering

    # The network connection is now open, lets fire up SSL

    $ctx = Net::SSLeay::CTX_new() or die_now("Failed to create SSL_CTX $!");
    Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL)
         or die_if_ssl_error("ssl ctx set options");
    $ssl = Net::SSLeay::new($ctx) or die_now("Failed to create SSL $!");
    Net::SSLeay::set_fd($ssl, fileno(S));   # Must use fileno
    $res = Net::SSLeay::connect($ssl) and die_if_ssl_error("ssl connect");
    print "Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n";

    # Exchange data

    $res = Net::SSLeay::write($ssl, $msg);  # Perl knows how long $msg is
    die_if_ssl_error("ssl write");
    CORE::shutdown S, 1;  # Half close --> No more output, sends EOF to server
    $got = Net::SSLeay::read($ssl);         # Perl returns undef on failure
    die_if_ssl_error("ssl read");
    print $got;

    Net::SSLeay::free ($ssl);               # Tear down connection
    Net::SSLeay::CTX_free ($ctx);
    close S;

The following is a simple SSLeay echo server (non forking):

    #!/usr/bin/perl -w
    use Socket;
    use Net::SSLeay qw(die_now die_if_ssl_error);
    Net::SSLeay::load_error_strings();
    Net::SSLeay::SSLeay_add_ssl_algorithms();
    Net::SSLeay::randomize();

    $our_ip = "\0\0\0\0"; # Bind to all interfaces
    $port = 1235;
    $sockaddr_template = 'S n a4 x8';
    $our_serv_params = pack ($sockaddr_template, &AF_INET, $port, $our_ip);

    socket (S, &AF_INET, &SOCK_STREAM, 0)  or die "socket: $!";
    bind (S, $our_serv_params)             or die "bind:   $!";
    listen (S, 5)                          or die "listen: $!";
    $ctx = Net::SSLeay::CTX_new ()         or die_now("CTX_new ($ctx): $!");
    Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL)
         or die_if_ssl_error("ssl ctx set options");

    # Following will ask password unless private key is not encrypted
    Net::SSLeay::CTX_use_RSAPrivateKey_file ($ctx, 'plain-rsa.pem',
                                             &Net::SSLeay::FILETYPE_PEM);
    die_if_ssl_error("private key");
    Net::SSLeay::CTX_use_certificate_file ($ctx, 'plain-cert.pem',
                                            &Net::SSLeay::FILETYPE_PEM);
    die_if_ssl_error("certificate");

    while (1) {
        print "Accepting connections...\n";
        ($addr = accept (NS, S))           or die "accept: $!";
        select (NS); $| = 1; select (STDOUT);  # Piping hot!

        ($af,$client_port,$client_ip) = unpack($sockaddr_template,$addr);
        @inetaddr = unpack('C4',$client_ip);
        print "$af connection from " .
        join ('.', @inetaddr) . ":$client_port\n";

        # We now have a network connection, lets fire up SSLeay...

        $ssl = Net::SSLeay::new($ctx)      or die_now("SSL_new ($ssl): $!");
        Net::SSLeay::set_fd($ssl, fileno(NS));

        $err = Net::SSLeay::accept($ssl) and die_if_ssl_error('ssl accept');
        print "Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n";

        # Connected. Exchange some data.

        $got = Net::SSLeay::read($ssl);     # Returns undef on fail
        die_if_ssl_error("ssl read");
        print "Got `$got' (" . length ($got) . " chars)\n";

        Net::SSLeay::write ($ssl, uc ($got)) or die "write: $!";
        die_if_ssl_error("ssl write");

        Net::SSLeay::free ($ssl);           # Tear down connection
        close NS;
    }

Yet another echo server. This one runs from C</etc/inetd.conf> so it avoids
all the socket code overhead. Only caveat is opening an rsa key file -
it had better be without any encryption or else it will not know where
to ask for the password. Note how C<STDIN> and C<STDOUT> are wired to SSL.

    #!/usr/bin/perl
    # /etc/inetd.conf
    #    ssltst stream tcp nowait root /path/to/server.pl server.pl
    # /etc/services
    #    ssltst        1234/tcp

    use Net::SSLeay qw(die_now die_if_ssl_error);
    Net::SSLeay::load_error_strings();
    Net::SSLeay::SSLeay_add_ssl_algorithms();
    Net::SSLeay::randomize();

    chdir '/key/dir' or die "chdir: $!";
    $| = 1;  # Piping hot!
    open LOG, ">>/dev/console" or die "Can't open log file $!";
    select LOG; print "server.pl started\n";

    $ctx = Net::SSLeay::CTX_new()     or die_now "CTX_new ($ctx) ($!)";
    $ssl = Net::SSLeay::new($ctx)     or die_now "new ($ssl) ($!)";
    Net::SSLeay::set_options($ssl, &Net::SSLeay::OP_ALL)
        and die_if_ssl_error("ssl set options");

    # We get already open network connection from inetd, now we just
    # need to attach SSLeay to STDIN and STDOUT
    Net::SSLeay::set_rfd($ssl, fileno(STDIN));
    Net::SSLeay::set_wfd($ssl, fileno(STDOUT));

    Net::SSLeay::use_RSAPrivateKey_file ($ssl, 'plain-rsa.pem',
                                         Net::SSLeay::FILETYPE_PEM);
    die_if_ssl_error("private key");
    Net::SSLeay::use_certificate_file ($ssl, 'plain-cert.pem',
                                       Net::SSLeay::FILETYPE_PEM);
    die_if_ssl_error("certificate");

    Net::SSLeay::accept($ssl) and die_if_ssl_err("ssl accept: $!");
    print "Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n";

    $got = Net::SSLeay::read($ssl);
    die_if_ssl_error("ssl read");
    print "Got `$got' (" . length ($got) . " chars)\n";

    Net::SSLeay::write ($ssl, uc($got)) or die "write: $!";
    die_if_ssl_error("ssl write");

    Net::SSLeay::free ($ssl);         # Tear down the connection
    Net::SSLeay::CTX_free ($ctx);
    close LOG;

There are also a number of example/test programs in the examples directory:

    sslecho.pl   -  A simple server, not unlike the one above
    minicli.pl   -  Implements a client using low level SSLeay routines
    sslcat.pl    -  Demonstrates using high level sslcat utility function
    get_page.pl  -  Is a utility for getting html pages from secure servers
    callback.pl  -  Demonstrates certificate verification and callback usage
    stdio_bulk.pl       - Does SSL over Unix pipes
    ssl-inetd-serv.pl   - SSL server that can be invoked from inetd.conf
    httpd-proxy-snif.pl - Utility that allows you to see how a browser
                          sends https request to given server and what reply
                          it gets back (very educative :-)
    makecert.pl  -  Creates a self signed cert (does not use this module)

=head1 INSTALLATION

See README and README.* in the distribution directory for installation guidance on a variety of platforms.

=head1 LIMITATIONS

C<Net::SSLeay::read()> uses an internal buffer of 32KB, thus no single read
will return more. In practice one read returns much less, usually
as much as fits in one network packet. To work around this,
you should use a loop like this:

    $reply = '';
    while ($got = Net::SSLeay::read($ssl)) {
        last if print_errs('SSL_read');
        $reply .= $got;
    }

Although there is no built-in limit in C<Net::SSLeay::write()>, the network
packet size limitation applies here as well, thus use:

    $written = 0;

    while ($written < length($message)) {
        $written += Net::SSLeay::write($ssl, substr($message, $written));
        last if print_errs('SSL_write');
    }

Or alternatively you can just use the following convenience functions:

    Net::SSLeay::ssl_write_all($ssl, $message) or die "ssl write failure";
    $got = Net::SSLeay::ssl_read_all($ssl) or die "ssl read failure";

=head1 KNOWN BUGS AND CAVEATS

LibreSSL versions in the 3.1 - 3.3 series contain a TLS 1.3 implementation that
is not fully compatible with the libssl API, but is still advertised during
protocol auto-negotiation. If you encounter problems or unexpected behaviour
with SSL or SSL_CTX objects whose protocol version was automatically negotiated
and libssl is provided by any of these versions of LibreSSL, it could be because
the peers negotiated to use TLS 1.3 - try setting the maximum protocol version
to TLS 1.2 (via C<Net::SSLeay::set_max_proto_version()> or
C<Net::SSLeay::CTX_set_max_proto_version()>) before establishing the connection.
The first stable LibreSSL version with a fully libssl-compatible TLS 1.3
implementation is 3.4.1.

An OpenSSL bug CVE-2015-0290 "OpenSSL Multiblock Corrupted Pointer Issue"
can cause POST requests of over 90kB to fail or crash. This bug is reported to be fixed in
OpenSSL 1.0.2a.

Autoloader emits a

    Argument "xxx" isn't numeric in entersub at blib/lib/Net/SSLeay.pm'

warning if die_if_ssl_error is made autoloadable. If you figure out why,
drop me a line.

Callback set using C<SSL_set_verify()> does not appear to work. This may
well be an openssl problem (e.g. see C<ssl/ssl_lib.c> line 1029). Try using
C<SSL_CTX_set_verify()> instead and do not be surprised if even this stops
working in future versions.

Callback and certificate verification stuff is generally too little tested.

Random numbers are not initialized randomly enough, especially if you
do not have C</dev/random> and/or C</dev/urandom> (such as in Solaris
platforms - but it's been suggested that cryptorand daemon from the SUNski
package solves this). In this case you should investigate third party
software that can emulate these devices, e.g. by way of a named pipe
to some program.

Another gotcha with random number initialization is randomness
depletion. This phenomenon, which has been extensively discussed in
OpenSSL, Apache-SSL, and Apache-mod_ssl forums, can cause your
script to block if you use C</dev/random> or to operate insecurely
if you use C</dev/urandom>. What happens is that when too much
randomness is drawn from the operating system's randomness pool
then randomness can temporarily be unavailable. C</dev/random> solves
this problem by waiting until enough randomness can be gathered - and
this can take a long time since blocking reduces activity in the
machine and less activity provides less random events: a vicious circle.
C</dev/urandom> solves this dilemma more pragmatically by simply returning
predictable "random" numbers. Some C</dev/urandom> emulation software
however actually seems to implement C</dev/random> semantics. Caveat emptor.

I've been pointed to two such daemons by Mik Firestone <mik@@speed.stdio._com>
who has used them on Solaris 8:

=over

=item 1

Entropy Gathering Daemon (EGD) at L<https://egd.sourceforge.net/>

=item 2

Pseudo-random number generating daemon (PRNGD) at
L<https://prngd.sourceforge.net/>

=back

If you are using the low level API functions to communicate with other
SSL implementations, you would do well to call

    Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL)
        or die_if_ssl_error("ssl ctx set options");

to cope with some well know bugs in some other SSL
implementations. The high level API functions always set all known
compatibility options.

Sometimes C<sslcat()> (and the high level HTTPS functions that build on it)
is too fast in signaling the EOF to legacy HTTPS servers. This causes
the server to return empty page. To work around this problem you can
set the global variable

    $Net::SSLeay::slowly = 1;   # Add sleep so broken servers can keep up

HTTP/1.1 is not supported. Specifically this module does not know to
issue or serve multiple http requests per connection. This is a serious
shortcoming, but using the SSL session cache on your server helps to
alleviate the CPU load somewhat.

As of version 1.09 many newer OpenSSL auxiliary functions were
added (from C<REM_AUTOMATICALLY_GENERATED_1_09> onwards in C<SSLeay.xs>).
Unfortunately I have not had any opportunity to test these. Some of
them are trivial enough that I believe they "just work", but others
have rather complex interfaces with function pointers and all. In these
cases you should proceed wit great caution.

This module defaults to using OpenSSL automatic protocol negotiation
code for automatically detecting the version of the SSL/TLS protocol
that the other end talks. With most web servers this works just
fine, but once in a while I get complaints from people that the module
does not work with some web servers. Usually this can be solved
by explicitly setting the protocol version, e.g.

    $Net::SSLeay::ssl_version = 2;  # Insist on SSLv2
    $Net::SSLeay::ssl_version = 3;  # Insist on SSLv3
    $Net::SSLeay::ssl_version = 10; # Insist on TLSv1
    $Net::SSLeay::ssl_version = 11; # Insist on TLSv1.1
    $Net::SSLeay::ssl_version = 12; # Insist on TLSv1.2
    $Net::SSLeay::ssl_version = 13; # Insist on TLSv1.3

Although the autonegotiation is nice to have, the SSL standards
do not formally specify any such mechanism. Most of the world has
accepted the SSLeay/OpenSSL way of doing it as the de facto standard. But
for the few that think differently, you have to explicitly speak
the correct version. This is not really a bug, but rather a deficiency
in the standards. If a site refuses to respond or sends back some
nonsensical error codes (at the SSL handshake level), try this option
before mailing me.

On some systems, OpenSSL may be compiled without support for SSLv2.
If this is the case, Net::SSLeay will warn if ssl_version has been set
to 2.

The high level API returns the certificate of the peer, thus allowing
one to check what certificate was supplied. However, you will only be
able to check the certificate after the fact, i.e. you already sent
your form data by the time you find out that you did not trust them,
oops.

So, while being able to know the certificate after the fact is surely
useful, the security minded would still choose to do the connection
and certificate verification first and only then exchange data
with the site. Currently none of the high level API functions do
this, thus you would have to program it using the low level API. A
good place to start is to see how the C<Net::SSLeay::http_cat()> function
is implemented.

The high level API functions use a global file handle C<SSLCAT_S>
internally. This really should not be a problem because there is no
way to interleave the high level API functions, unless you use threads
(but threads are not very well supported in perl anyway). However, you
may run into problems if you call undocumented internal functions in an
interleaved fashion. The best solution is to "require Net::SSLeay" in
one thread after all the threads have been created.

=head1 DIAGNOSTICS

=over

=item Random number generator not seeded!!!

B<(W)> This warning indicates that C<randomize()> was not able to read
C</dev/random> or C</dev/urandom>, possibly because your system does not
have them or they are differently named. You can still use SSL, but
the encryption will not be as strong.

=item open_tcp_connection: destination host not found:`server' (port 123) ($!)

Name lookup for host named C<server> failed.

=item open_tcp_connection: failed `server', 123 ($!)

The name was resolved, but establishing the TCP connection failed.

=item msg 123: 1 - error:140770F8:SSL routines:SSL23_GET_SERVER_HELLO:unknown proto

SSLeay error string. The first number (123) is the PID, the second number
(1) indicates the position of the error message in SSLeay error stack.
You often see a pile of these messages as errors cascade.

=item msg 123: 1 - error:02001002::lib(2) :func(1) :reason(2)

The same as above, but you didn't call load_error_strings() so SSLeay
couldn't verbosely explain the error. You can still find out what it
means with this command:

    /usr/local/ssl/bin/ssleay errstr 02001002

=item Password is being asked for private key

This is normal behaviour if your private key is encrypted. Either
you have to supply the password or you have to use an unencrypted
private key. Scan OpenSSL.org for the FAQ that explains how to
do this (or just study examples/makecert.pl which is used
during C<make test> to do just that).

=back

=head1 SECURITY

You can mitigate some of the security vulnerabilities that might be present in your SSL/TLS application:

=head2 BEAST Attack

=over

=item * L<https://web.archive.org/web/20140424022931/https://blogs.cisco.com/security/beat-the-beast-with-tls>

=item * L<https://community.qualys.com/blogs/securitylabs/2011/10/17/mitigating-the-beast-attack-on-tls>

=item * L<https://blog.zoller.lu/2011/09/beast-summary-tls-cbc-countermeasures.html>

=back

The BEAST attack relies on a weakness in the way CBC mode is used in SSL/TLS.
In OpenSSL versions 0.9.6d and later, the protocol-level mitigation is enabled by default,
thus making it not vulnerable to the BEAST attack.

Solutions:

=over

=item * Compile with OpenSSL versions 0.9.6d or later, which enables SSL_OP_ALL by default

=item * Ensure SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS is not enabled (its not enabled by default)

=item * Don't support SSLv2, SSLv3

=item * Actively control the ciphers your server supports with set_cipher_list:

=back

    Net::SSLeay::set_cipher_list($ssl, 'RC4-SHA:HIGH:!ADH');

=head2 Session Resumption

=over

=item * L<https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_options.html>

=back

The SSL Labs vulnerability test on your SSL server might report in red:

Session resumption      No (IDs assigned but not accepted)

This report is not really bug or a vulnerability, since the server will not
accept session resumption requests.
However, you can prevent this noise in the report by disabling the session cache altogether:

    Net::SSLeay::CTX_set_session_cache_mode($ssl_ctx, Net::SSLeay::SESS_CACHE_OFF());
    # Use 0 if you don't have SESS_CACHE_OFF constant.

=head2 Secure Renegotiation and DoS Attack

=over

=item * L<https://community.qualys.com/blogs/securitylabs/2011/10/31/tls-renegotiation-and-denial-of-service-attacks>

=back

This is not a "security flaw," it is more of a DoS vulnerability.

Solutions:

=over

=item * Do not support SSLv2

=item * Do not set the SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION option

=item * Compile with OpenSSL 0.9.8m or later

=back

=head1 BUGS

If you encounter a problem with this module that you believe is a bug, please
L<create a new issue|https://github.com/radiator-software/p5-net-ssleay/issues/new>
in the Net-SSLeay GitHub repository. Please make sure your bug report includes
the following information:

=over

=item * the code you are trying to run;

=item * your operating system name and version;

=item * the output of C<perl -V>;

=item * the version of OpenSSL or LibreSSL you are using.

=back

=head1 AUTHOR

Originally written by Sampo Kellomäki.

Maintained by Florian Ragwitz between November 2005 and January 2010.

Maintained by Mike McCauley between November 2005 and June 2018.

Maintained by Chris Novakovic, Tuure Vartiainen and Heikki Vatiainen since June 2018.

=head1 COPYRIGHT

Copyright (c) 1996-2003 Sampo Kellomäki <sampo@iki.fi>

Copyright (c) 2005-2010 Florian Ragwitz <rafl@debian.org>

Copyright (c) 2005-2018 Mike McCauley <mikem@airspayce.com>

Copyright (c) 2018- Chris Novakovic <chris@chrisn.me.uk>

Copyright (c) 2018- Tuure Vartiainen <vartiait@radiatorsoftware.com>

Copyright (c) 2018- Heikki Vatiainen <hvn@radiatorsoftware.com>

All rights reserved.

=head1 LICENSE

This module is released under the terms of the Artistic License 2.0. For
details, see the C<LICENSE> file distributed with Net-SSLeay's source code.

=head1 SEE ALSO

    Net::SSLeay::Handle                      - File handle interface
    ./examples                               - Example servers and a clients
    <https://www.openssl.org/>               - OpenSSL source, documentation, etc
    openssl-users-request@openssl.org        - General OpenSSL mailing list
    <https://www.ietf.org/rfc/rfc2246.txt>   - TLS 1.0 specification
    <https://www.w3c.org>                    - HTTP specifications
    <https://www.ietf.org/rfc/rfc2617.txt>   - How to send password
    <https://egd.sourceforge.net/>           - Entropy Gathering Daemon (EGD)
    <https://prngd.sourceforge.net/>         - pseudo-random number generating daemon (PRNGD)
    perl(1)
    perlref(1)
    perllol(1)
    perldoc ~openssl/doc/ssl/SSL_CTX_set_verify.pod