You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2024/07/16 15:39:17 UTC
(tomcat) branch main updated: Drop old FFM modules
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 4fea671f98 Drop old FFM modules
4fea671f98 is described below
commit 4fea671f9882577bfcd2619d2b4682e4f3f89e09
Author: remm <re...@apache.org>
AuthorDate: Tue Jul 16 17:38:50 2024 +0200
Drop old FFM modules
The code has been merged in all current branches.
---
modules/openssl-foreign/LICENSE | 201 -
modules/openssl-foreign/README.md | 89 -
modules/openssl-foreign/addlicense.sh | 22 -
modules/openssl-foreign/license.header | 17 -
modules/openssl-foreign/openssl-tomcat.conf | 366 --
modules/openssl-foreign/openssl.h | 31 -
modules/openssl-foreign/pom.xml | 94 -
.../util/net/openssl/panama/OpenSSLContext.java | 1422 -----
.../util/net/openssl/panama/OpenSSLEngine.java | 1697 ------
.../net/openssl/panama/OpenSSLImplementation.java | 51 -
.../util/net/openssl/panama/OpenSSLLibrary.java | 446 --
.../openssl/panama/OpenSSLLifecycleListener.java | 130 -
.../net/openssl/panama/OpenSSLSessionContext.java | 155 -
.../net/openssl/panama/OpenSSLSessionStats.java | 128 -
.../util/net/openssl/panama/OpenSSLStatus.java | 60 -
.../util/net/openssl/panama/OpenSSLUtil.java | 139 -
.../net/openssl/panama/OpenSSLX509Certificate.java | 192 -
.../openssl/SSL_CTX_set_alpn_select_cb$cb.java | 70 -
.../SSL_CTX_set_cert_verify_callback$cb.java | 66 -
.../openssl/SSL_CTX_set_tmp_dh_callback$dh.java | 67 -
.../util/openssl/SSL_CTX_set_verify$callback.java | 66 -
.../util/openssl/SSL_set_info_callback$cb.java | 66 -
.../util/openssl/SSL_set_verify$callback.java | 66 -
.../org/apache/tomcat/util/openssl/openssl_h.java | 6437 --------------------
.../util/openssl/openssl_h_Compatibility.java | 120 -
.../tomcat/util/openssl/openssl_h_Macros.java | 293 -
.../tomcat/util/openssl/pem_password_cb.java | 81 -
.../net/openssl/panama/LocalStrings.properties | 106 -
modules/openssl-java17/README.md | 86 -
modules/openssl-java17/addlicense.sh | 22 -
modules/openssl-java17/license.header | 17 -
modules/openssl-java17/openssl-tomcat.conf | 357 --
modules/openssl-java17/openssl.h | 32 -
modules/openssl-java17/pom.xml | 103 -
.../util/net/openssl/panama/OpenSSLContext.java | 1408 -----
.../util/net/openssl/panama/OpenSSLEngine.java | 1846 ------
.../net/openssl/panama/OpenSSLImplementation.java | 51 -
.../openssl/panama/OpenSSLLifecycleListener.java | 465 --
.../net/openssl/panama/OpenSSLSessionContext.java | 166 -
.../net/openssl/panama/OpenSSLSessionStats.java | 128 -
.../util/net/openssl/panama/OpenSSLStatus.java | 60 -
.../util/net/openssl/panama/OpenSSLUtil.java | 128 -
.../net/openssl/panama/OpenSSLX509Certificate.java | 190 -
.../apache/tomcat/util/openssl/RuntimeHelper.java | 235 -
.../SSL_CTX_set_cert_verify_callback$cb.java | 47 -
.../openssl/SSL_CTX_set_tmp_dh_callback$dh.java | 47 -
.../util/openssl/SSL_set_info_callback$cb.java | 47 -
.../apache/tomcat/util/openssl/constants$0.java | 80 -
.../apache/tomcat/util/openssl/constants$1.java | 82 -
.../apache/tomcat/util/openssl/constants$10.java | 89 -
.../apache/tomcat/util/openssl/constants$11.java | 86 -
.../apache/tomcat/util/openssl/constants$12.java | 80 -
.../apache/tomcat/util/openssl/constants$13.java | 82 -
.../apache/tomcat/util/openssl/constants$14.java | 84 -
.../apache/tomcat/util/openssl/constants$15.java | 74 -
.../apache/tomcat/util/openssl/constants$16.java | 86 -
.../apache/tomcat/util/openssl/constants$17.java | 86 -
.../apache/tomcat/util/openssl/constants$18.java | 77 -
.../apache/tomcat/util/openssl/constants$19.java | 81 -
.../apache/tomcat/util/openssl/constants$2.java | 80 -
.../apache/tomcat/util/openssl/constants$20.java | 81 -
.../apache/tomcat/util/openssl/constants$21.java | 69 -
.../apache/tomcat/util/openssl/constants$22.java | 80 -
.../apache/tomcat/util/openssl/constants$23.java | 80 -
.../apache/tomcat/util/openssl/constants$24.java | 85 -
.../apache/tomcat/util/openssl/constants$25.java | 83 -
.../apache/tomcat/util/openssl/constants$26.java | 86 -
.../apache/tomcat/util/openssl/constants$27.java | 86 -
.../apache/tomcat/util/openssl/constants$28.java | 80 -
.../apache/tomcat/util/openssl/constants$29.java | 32 -
.../apache/tomcat/util/openssl/constants$3.java | 79 -
.../apache/tomcat/util/openssl/constants$4.java | 81 -
.../apache/tomcat/util/openssl/constants$5.java | 79 -
.../apache/tomcat/util/openssl/constants$6.java | 81 -
.../apache/tomcat/util/openssl/constants$7.java | 81 -
.../apache/tomcat/util/openssl/constants$8.java | 81 -
.../apache/tomcat/util/openssl/constants$9.java | 88 -
.../tomcat/util/openssl/openssl_compat_h.java | 130 -
.../org/apache/tomcat/util/openssl/openssl_h.java | 2154 -------
.../net/openssl/panama/LocalStrings.properties | 102 -
modules/openssl-java21/LICENSE | 201 -
modules/openssl-java21/README.md | 90 -
modules/openssl-java21/addlicense.sh | 22 -
modules/openssl-java21/license.header | 17 -
modules/openssl-java21/openssl-tomcat.conf | 357 --
modules/openssl-java21/openssl.h | 31 -
modules/openssl-java21/pom.xml | 98 -
.../util/net/openssl/panama/OpenSSLContext.java | 1406 -----
.../util/net/openssl/panama/OpenSSLEngine.java | 1797 ------
.../net/openssl/panama/OpenSSLImplementation.java | 51 -
.../openssl/panama/OpenSSLLifecycleListener.java | 463 --
.../net/openssl/panama/OpenSSLSessionContext.java | 163 -
.../net/openssl/panama/OpenSSLSessionStats.java | 128 -
.../util/net/openssl/panama/OpenSSLStatus.java | 60 -
.../util/net/openssl/panama/OpenSSLUtil.java | 128 -
.../net/openssl/panama/OpenSSLX509Certificate.java | 192 -
.../apache/tomcat/util/openssl/Constants$root.java | 42 -
.../apache/tomcat/util/openssl/RuntimeHelper.java | 258 -
.../SSL_CTX_set_cert_verify_callback$cb.java | 50 -
.../openssl/SSL_CTX_set_tmp_dh_callback$dh.java | 50 -
.../util/openssl/SSL_set_info_callback$cb.java | 50 -
.../apache/tomcat/util/openssl/constants$0.java | 76 -
.../apache/tomcat/util/openssl/constants$1.java | 78 -
.../apache/tomcat/util/openssl/constants$10.java | 85 -
.../apache/tomcat/util/openssl/constants$11.java | 82 -
.../apache/tomcat/util/openssl/constants$12.java | 76 -
.../apache/tomcat/util/openssl/constants$13.java | 78 -
.../apache/tomcat/util/openssl/constants$14.java | 80 -
.../apache/tomcat/util/openssl/constants$15.java | 80 -
.../apache/tomcat/util/openssl/constants$16.java | 82 -
.../apache/tomcat/util/openssl/constants$17.java | 82 -
.../apache/tomcat/util/openssl/constants$18.java | 73 -
.../apache/tomcat/util/openssl/constants$19.java | 77 -
.../apache/tomcat/util/openssl/constants$2.java | 76 -
.../apache/tomcat/util/openssl/constants$20.java | 77 -
.../apache/tomcat/util/openssl/constants$21.java | 84 -
.../apache/tomcat/util/openssl/constants$22.java | 76 -
.../apache/tomcat/util/openssl/constants$23.java | 76 -
.../apache/tomcat/util/openssl/constants$24.java | 81 -
.../apache/tomcat/util/openssl/constants$25.java | 79 -
.../apache/tomcat/util/openssl/constants$26.java | 82 -
.../apache/tomcat/util/openssl/constants$27.java | 82 -
.../apache/tomcat/util/openssl/constants$28.java | 76 -
.../apache/tomcat/util/openssl/constants$29.java | 34 -
.../apache/tomcat/util/openssl/constants$3.java | 75 -
.../apache/tomcat/util/openssl/constants$4.java | 77 -
.../apache/tomcat/util/openssl/constants$5.java | 75 -
.../apache/tomcat/util/openssl/constants$6.java | 77 -
.../apache/tomcat/util/openssl/constants$7.java | 77 -
.../apache/tomcat/util/openssl/constants$8.java | 77 -
.../apache/tomcat/util/openssl/constants$9.java | 84 -
.../tomcat/util/openssl/openssl_compat_h.java | 121 -
.../org/apache/tomcat/util/openssl/openssl_h.java | 3447 -----------
.../net/openssl/panama/LocalStrings.properties | 97 -
134 files changed, 34531 deletions(-)
diff --git a/modules/openssl-foreign/LICENSE b/modules/openssl-foreign/LICENSE
deleted file mode 100644
index 261eeb9e9f..0000000000
--- a/modules/openssl-foreign/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/modules/openssl-foreign/README.md b/modules/openssl-foreign/README.md
deleted file mode 100644
index c755eb38be..0000000000
--- a/modules/openssl-foreign/README.md
+++ /dev/null
@@ -1,89 +0,0 @@
-# OpenSSL support for Apache Tomcat
-
-## This module is experimental
-
-It uses the JEP 454 API. More details on this API are available
-at `https://openjdk.java.net/jeps/454`.
-
-## Building
-
-The module can be built using Java 22 preview 20+. It can be built and run
-with Apache Tomcat 9.0 or newer.
-
-## Running
-
-The module uses the OpenSSL 3.0 API. It requires an API compatible version of
-OpenSSL or a compatible alternative library, that can be loaded from the JVM
-library path. OpenSSL 1.1 is also supported.
-
-Copy `tomcat-coyote-openssl-1.0.jar` to the Apache Tomcat `lib` folder.
-
-Remove `AprLifecycleListener` from `server.xml`. The
-`org.apache.tomcat.util.net.openssl.panama.OpenSSLLifecycleListener` can be
-used as a replacement with the same configuration options (such as FIPS)
-and shutdown cleanup, but is not required.
-
-Define a `Connector` using the value
-`org.apache.tomcat.util.net.openssl.panama.OpenSSLImplementation` for the
-`sslImplementationName` attribute.
-
-Example connector:
-```
- <Connector port="8443" protocol="HTTP/1.1"
- SSLEnabled="true" scheme="https" secure="true"
- socket.directBuffer="true" socket.directSslBuffer="true"
- sslImplementationName="org.apache.tomcat.util.net.openssl.panama.OpenSSLImplementation">
- <SSLHostConfig certificateVerification="none">
- <Certificate certificateKeyFile="${catalina.home}/conf/localhost-rsa-key.pem"
- certificateFile="${catalina.home}/conf/localhost-rsa-cert.pem"
- certificateChainFile="${catalina.home}/conf/localhost-rsa-chain.pem"
- type="RSA" />
- </SSLHostConfig>
- <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
- </Connector>
-```
-
-Run Tomcat using the additional Java options that allow access to the API and
-native code:
-```
-export JAVA_OPTS="--enable-native-access=ALL-UNNAMED"
-```
-
-## Generating the OpenSSL API code using jextract (optional)
-
-jextract is now available in its own standalone repository. Clone
-`https://github.com/openjdk/jextract` in some location and
-checkout the branch that supports Java 22. Please refer to the
-instructions from the repository for building. It should be the
-`panama` branch.
-
-This step is only useful to be able to use additional native APIs from OpenSSL
-or stdlib.
-
-Find include paths using `gcc -xc -E -v -`, on Fedora it is
-`/usr/lib/gcc/x86_64-redhat-linux/12/include`. Edit `openssl-tomcat.conf`
-accordingly to set the appropriate path.
-
-```
-export JEXTRACT_HOME=<pathto>/jextract/build/jextract
-$JEXTRACT_HOME/bin/jextract @openssl-tomcat.conf openssl.h
-```
-Note: The build path for the JDK will be different on other platforms.
-
-The code included was generated using OpenSSL 3.0. As long as things remain
-API compatible, the generated code will still work.
-
-The `openssl-tomcat.conf` will generate a trimmed down OpenSSL API. When
-developing new features, the full API can be generated instead using:
-```
-$JEXTRACT_HOME/bin/jextract --source -t org.apache.tomcat.util.openssl -lssl -I /usr/lib/gcc/x86_64-redhat-linux/12/include openssl.h --output src/main/java
-```
-
-The `openssl.conf` file lists all the API calls and constants that can be
-generated using jextract, as a reference to what is available. Some macros are
-not supported and have to be reproduced in code.
-
-Before committing updated generated files, they need to have the license header
-added. The `addlicense.sh` script can do that and process all Java source files
-in the `src/main/java/org/apache/tomcat/util/openssl` directory.
-
diff --git a/modules/openssl-foreign/addlicense.sh b/modules/openssl-foreign/addlicense.sh
deleted file mode 100755
index 6349703675..0000000000
--- a/modules/openssl-foreign/addlicense.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-for generated in src/main/java/org/apache/tomcat/util/openssl/*.java; do
- cat license.header $generated >> $generated.$$
- mv $generated.$$ $generated
- echo Updated $generated
-done
diff --git a/modules/openssl-foreign/license.header b/modules/openssl-foreign/license.header
deleted file mode 100644
index 4b326ae5c2..0000000000
--- a/modules/openssl-foreign/license.header
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
diff --git a/modules/openssl-foreign/openssl-tomcat.conf b/modules/openssl-foreign/openssl-tomcat.conf
deleted file mode 100644
index 8ca92f0fa5..0000000000
--- a/modules/openssl-foreign/openssl-tomcat.conf
+++ /dev/null
@@ -1,366 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
---source
--t org.apache.tomcat.util.openssl
--lssl
-# Configure include path
--I /usr/lib/gcc/x86_64-redhat-linux/12/include
---output src/main/java
-
-#### Extracted from: /usr/include/openssl/asn1.h
-
---include-function ASN1_STRING_get0_data # header: /usr/include/openssl/asn1.h
---include-function ASN1_STRING_length # header: /usr/include/openssl/asn1.h
-
-#### Extracted from: /usr/include/openssl/bio.h
-
---include-function BIO_ctrl # header: /usr/include/openssl/bio.h
---include-function BIO_ctrl_pending # header: /usr/include/openssl/bio.h
---include-function BIO_free # header: /usr/include/openssl/bio.h
---include-function BIO_new # header: /usr/include/openssl/bio.h
---include-function BIO_new_bio_pair # header: /usr/include/openssl/bio.h
---include-function BIO_new_file # header: /usr/include/openssl/bio.h
---include-function BIO_read # header: /usr/include/openssl/bio.h
---include-function BIO_s_bio # header: /usr/include/openssl/bio.h
---include-function BIO_s_file # header: /usr/include/openssl/bio.h
---include-function BIO_s_mem # header: /usr/include/openssl/bio.h
---include-function BIO_write # header: /usr/include/openssl/bio.h
---include-constant BIO_CLOSE # header: /usr/include/openssl/bio.h
---include-constant BIO_CTRL_RESET # header: /usr/include/openssl/bio.h
---include-constant BIO_C_SET_FILENAME # header: /usr/include/openssl/bio.h
---include-constant BIO_FP_READ # header: /usr/include/openssl/bio.h
-
-#### Extracted from: /usr/include/openssl/bn.h
-
---include-function BN_get_rfc2409_prime_1024 # header: /usr/include/openssl/bn.h
---include-function BN_get_rfc2409_prime_768 # header: /usr/include/openssl/bn.h
---include-function BN_get_rfc3526_prime_1536 # header: /usr/include/openssl/bn.h
---include-function BN_get_rfc3526_prime_2048 # header: /usr/include/openssl/bn.h
---include-function BN_get_rfc3526_prime_3072 # header: /usr/include/openssl/bn.h
---include-function BN_get_rfc3526_prime_4096 # header: /usr/include/openssl/bn.h
---include-function BN_get_rfc3526_prime_6144 # header: /usr/include/openssl/bn.h
---include-function BN_get_rfc3526_prime_8192 # header: /usr/include/openssl/bn.h
---include-function BN_new # header: /usr/include/openssl/bn.h
---include-function BN_set_word # header: /usr/include/openssl/bn.h
-
-#### Extracted from: /usr/include/openssl/crypto.h
-
---include-function CRYPTO_free # header: /usr/include/openssl/crypto.h
---include-function OpenSSL_version # header: /usr/include/openssl/crypto.h
---include-function OpenSSL_version_num # header: /usr/include/openssl/crypto.h
---include-constant OPENSSL_INIT_ENGINE_ALL_BUILTIN # deprecated header: /usr/include/openssl/crypto.h
-
-#### Extracted from: /usr/include/openssl/dh.h
-
---include-function DH_free # deprecated header: /usr/include/openssl/dh.h
---include-function DH_new # deprecated header: /usr/include/openssl/dh.h
---include-function DH_set0_pqg # deprecated header: /usr/include/openssl/dh.h
-
-#### Extracted from: /usr/include/openssl/ec.h
-
---include-function d2i_ECPKParameters # header: /usr/include/openssl/ec.h
---include-function EC_GROUP_free # header: /usr/include/openssl/ec.h
---include-function EC_GROUP_get_curve_name # header: /usr/include/openssl/ec.h
---include-function EC_KEY_free # deprecated header: /usr/include/openssl/ec.h
---include-function EC_KEY_new_by_curve_name # deprecated header: /usr/include/openssl/ec.h
-
-#### Extracted from: /usr/include/openssl/engine.h
-
---include-function ENGINE_by_id # deprecated header: /usr/include/openssl/engine.h
---include-function ENGINE_ctrl_cmd_string # deprecated header: /usr/include/openssl/engine.h
---include-function ENGINE_free # deprecated header: /usr/include/openssl/engine.h
---include-function ENGINE_load_private_key # deprecated header: /usr/include/openssl/engine.h
---include-function ENGINE_register_all_complete # deprecated header: /usr/include/openssl/engine.h
---include-function ENGINE_set_default # deprecated header: /usr/include/openssl/engine.h
---include-constant ENGINE_METHOD_ALL # deprecated header: /usr/include/openssl/engine.h
-
-#### Extracted from: /usr/include/openssl/err.h
-
---include-function ERR_clear_error # header: /usr/include/openssl/err.h
---include-function ERR_error_string # header: /usr/include/openssl/err.h
---include-function ERR_get_error # header: /usr/include/openssl/err.h
---include-function ERR_peek_last_error # header: /usr/include/openssl/err.h
---include-constant ERR_REASON_MASK # header: /usr/include/openssl/err.h
-
-#### Extracted from: /usr/include/openssl/evp.h
-
---include-function EVP_MD_fetch # header: /usr/include/openssl/evp.h
---include-function EVP_MD_free # header: /usr/include/openssl/evp.h
---include-function EVP_MD_get0_provider # header: /usr/include/openssl/evp.h
---include-function EVP_PKEY_get_base_id # header: /usr/include/openssl/evp.h
---include-function EVP_PKEY_get_bits # header: /usr/include/openssl/evp.h
---include-function EVP_PKEY_free # header: /usr/include/openssl/evp.h
---include-constant EVP_PKEY_DSA # header: /usr/include/openssl/evp.h
---include-constant EVP_PKEY_NONE # header: /usr/include/openssl/evp.h
---include-constant EVP_PKEY_RSA # header: /usr/include/openssl/evp.h
-
-#### Extracted from: /usr/include/openssl/obj_mac.h
-
---include-constant NID_info_access # header: /usr/include/openssl/obj_mac.h
-
-#### Extracted from: /usr/include/openssl/ocsp.h
-
---include-function OCSP_BASICRESP_free # header: /usr/include/openssl/ocsp.h
---include-function OCSP_CERTID_free # header: /usr/include/openssl/ocsp.h
---include-function OCSP_REQUEST_free # header: /usr/include/openssl/ocsp.h
---include-function OCSP_REQUEST_new # header: /usr/include/openssl/ocsp.h
---include-function OCSP_RESPONSE_free # header: /usr/include/openssl/ocsp.h
---include-function OCSP_cert_to_id # header: /usr/include/openssl/ocsp.h
---include-function OCSP_request_add0_id # header: /usr/include/openssl/ocsp.h
---include-function OCSP_response_get1_basic # header: /usr/include/openssl/ocsp.h
---include-function OCSP_response_status # header: /usr/include/openssl/ocsp.h
---include-function OCSP_resp_find # header: /usr/include/openssl/ocsp.h
---include-function OCSP_resp_get0 # header: /usr/include/openssl/ocsp.h
---include-function OCSP_single_get0_status # header: /usr/include/openssl/ocsp.h
---include-function d2i_OCSP_RESPONSE # header: /usr/include/openssl/ocsp.h
---include-function i2d_OCSP_REQUEST # header: /usr/include/openssl/ocsp.h
---include-constant OCSP_RESPONSE_STATUS_SUCCESSFUL # header: /usr/include/openssl/ocsp.h
---include-constant V_OCSP_CERTSTATUS_GOOD # header: /usr/include/openssl/ocsp.h
---include-constant V_OCSP_CERTSTATUS_REVOKED # header: /usr/include/openssl/ocsp.h
---include-constant V_OCSP_CERTSTATUS_UNKNOWN # header: /usr/include/openssl/ocsp.h
-
-#### Extracted from: /usr/include/openssl/opensslconf-x86_64.h
-
---include-constant OPENSSL_API_COMPAT # header: /usr/include/openssl/opensslconf-x86_64.h
---include-constant OPENSSL_FILE # header: /usr/include/openssl/opensslconf-x86_64.h
---include-constant OPENSSL_LINE # header: /usr/include/openssl/opensslconf-x86_64.h
---include-constant OPENSSL_MIN_API # header: /usr/include/openssl/opensslconf-x86_64.h
-
-#### Extracted from: /usr/include/openssl/pem.h
-
---include-function PEM_ASN1_read_bio # header: /usr/include/openssl/pem.h
---include-function PEM_read_bio_DHparams # deprecated header: /usr/include/openssl/pem.h
---include-function PEM_read_bio_ECPKParameters # deprecated header: /usr/include/openssl/pem.h
---include-function PEM_read_bio_Parameters # header: /usr/include/openssl/pem.h
---include-function PEM_read_bio_PrivateKey # header: /usr/include/openssl/pem.h
---include-function PEM_read_bio_X509_AUX # header: /usr/include/openssl/pem.h
---include-constant PEM_STRING_ECPARAMETERS # header: /usr/include/openssl/pem.h
-
-#### Extracted from: /usr/include/openssl/pemerr.h
-
---include-constant PEM_R_NO_START_LINE # header: /usr/include/openssl/pemerr.h
-
-#### Extracted from: /usr/include/openssl/pkcs12.h
-
---include-function PKCS12_free # header: /usr/include/openssl/pkcs12.h
---include-function PKCS12_parse # header: /usr/include/openssl/pkcs12.h
---include-function PKCS12_verify_mac # header: /usr/include/openssl/pkcs12.h
---include-function d2i_PKCS12_bio # header: /usr/include/openssl/pkcs12.h
-
-#### Extracted from: /usr/include/openssl/provider.h
-
---include-function OSSL_PROVIDER_get0_name # header: /usr/include/openssl/provider.h
-
-#### Extracted from: /usr/include/openssl/rand.h
-
---include-function RAND_load_file # header: /usr/include/openssl/rand.h
---include-function RAND_seed # header: /usr/include/openssl/rand.h
-
-#### Extracted from: /usr/include/openssl/ssl.h
-
---include-function OPENSSL_init_ssl # header: /usr/include/openssl/ssl.h
---include-function SSL_CIPHER_get_auth_nid # header: /usr/include/openssl/ssl.h
---include-function SSL_CIPHER_get_kx_nid # header: /usr/include/openssl/ssl.h
---include-function SSL_CIPHER_get_name # header: /usr/include/openssl/ssl.h
---include-function SSL_CONF_CTX_finish # header: /usr/include/openssl/ssl.h
---include-function SSL_CONF_CTX_free # header: /usr/include/openssl/ssl.h
---include-function SSL_CONF_CTX_new # header: /usr/include/openssl/ssl.h
---include-function SSL_CONF_CTX_set_flags # header: /usr/include/openssl/ssl.h
---include-function SSL_CONF_CTX_set_ssl_ctx # header: /usr/include/openssl/ssl.h
---include-function SSL_CONF_cmd # header: /usr/include/openssl/ssl.h
---include-function SSL_CONF_cmd_value_type # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_add_client_CA # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_check_private_key # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_clear_options # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_ctrl # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_free # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_get_cert_store # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_get_ciphers # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_get_client_CA_list # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_get_options # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_get_timeout # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_load_verify_locations # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_new # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_alpn_select_cb # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_cert_verify_callback # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_cipher_list # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_ciphersuites # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_client_CA_list # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_default_passwd_cb # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_default_verify_paths # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_options # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_session_id_context # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_timeout # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_tmp_dh_callback # deprecated header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set_verify # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_set0_tmp_dh_pkey # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_use_certificate # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_use_certificate_chain_file # header: /usr/include/openssl/ssl.h
---include-function SSL_CTX_use_PrivateKey # header: /usr/include/openssl/ssl.h
---include-function SSL_SESSION_get_id # header: /usr/include/openssl/ssl.h
---include-function SSL_SESSION_get_time # header: /usr/include/openssl/ssl.h
---include-function SSL_add_file_cert_subjects_to_stack # header: /usr/include/openssl/ssl.h
---include-function SSL_do_handshake # header: /usr/include/openssl/ssl.h
---include-function SSL_free # header: /usr/include/openssl/ssl.h
---include-function SSL_get_ciphers # header: /usr/include/openssl/ssl.h
---include-function SSL_get_current_cipher # header: /usr/include/openssl/ssl.h
---include-function SSL_get_ex_data_X509_STORE_CTX_idx # header: /usr/include/openssl/ssl.h
---include-function SSL_get_options # header: /usr/include/openssl/ssl.h
---include-function SSL_get_peer_cert_chain # header: /usr/include/openssl/ssl.h
---include-function SSL_get_privatekey # header: /usr/include/openssl/ssl.h
---include-function SSL_get_session # header: /usr/include/openssl/ssl.h
---include-function SSL_get_shutdown # header: /usr/include/openssl/ssl.h
---include-function SSL_get_version # header: /usr/include/openssl/ssl.h
---include-function SSL_get0_alpn_selected # header: /usr/include/openssl/ssl.h
---include-function SSL_get1_peer_certificate # header: /usr/include/openssl/ssl.h
---include-function SSL_in_init # header: /usr/include/openssl/ssl.h
---include-function SSL_load_client_CA_file # header: /usr/include/openssl/ssl.h
---include-function SSL_new # header: /usr/include/openssl/ssl.h
---include-function SSL_pending # header: /usr/include/openssl/ssl.h
---include-function SSL_read # header: /usr/include/openssl/ssl.h
---include-function SSL_renegotiate # header: /usr/include/openssl/ssl.h
---include-function SSL_renegotiate_pending # header: /usr/include/openssl/ssl.h
---include-function SSL_set_accept_state # header: /usr/include/openssl/ssl.h
---include-function SSL_set_bio # header: /usr/include/openssl/ssl.h
---include-function SSL_set_cipher_list # header: /usr/include/openssl/ssl.h
---include-function SSL_set_connect_state # header: /usr/include/openssl/ssl.h
---include-function SSL_set_info_callback # header: /usr/include/openssl/ssl.h
---include-function SSL_set_options # header: /usr/include/openssl/ssl.h
---include-function SSL_set_verify # header: /usr/include/openssl/ssl.h
---include-function SSL_set_verify_result # header: /usr/include/openssl/ssl.h
---include-function SSL_shutdown # header: /usr/include/openssl/ssl.h
---include-function SSL_verify_client_post_handshake # header: /usr/include/openssl/ssl.h
---include-function SSL_write # header: /usr/include/openssl/ssl.h
---include-function TLS_server_method # header: /usr/include/openssl/ssl.h
---include-constant SSL_CB_HANDSHAKE_DONE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CONF_FLAG_CERTIFICATE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CONF_FLAG_FILE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CONF_FLAG_SERVER # header: /usr/include/openssl/ssl.h
---include-constant SSL_CONF_FLAG_SHOW_ERRORS # header: /usr/include/openssl/ssl.h
---include-constant SSL_CONF_TYPE_DIR # header: /usr/include/openssl/ssl.h
---include-constant SSL_CONF_TYPE_FILE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CONF_TYPE_UNKNOWN # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_CHAIN_CERT # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_GET_SESS_CACHE_MODE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_GET_SESS_CACHE_SIZE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_ACCEPT # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_ACCEPT_GOOD # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_ACCEPT_RENEGOTIATE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_CACHE_FULL # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_CB_HIT # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_CONNECT # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_CONNECT_GOOD # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_CONNECT_RENEGOTIATE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_HIT # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_MISSES # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_NUMBER # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SESS_TIMEOUTS # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SET_DH_AUTO # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SET_GROUPS # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SET_MAX_PROTO_VERSION # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SET_MIN_PROTO_VERSION # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SET_SESS_CACHE_MODE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SET_SESS_CACHE_SIZE # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SET_TLSEXT_TICKET_KEYS # header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SET_TMP_DH # deprecated header: /usr/include/openssl/ssl.h
---include-constant SSL_CTRL_SET_TMP_ECDH # deprecated header: /usr/include/openssl/ssl.h
---include-constant SSL_ERROR_NONE # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_ALL # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_CIPHER_SERVER_PREFERENCE # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_NO_COMPRESSION # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_NO_SSLv2 # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_NO_SSLv3 # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_NO_TICKET # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_NO_TLSv1 # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_NO_TLSv1_1 # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_NO_TLSv1_2 # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_NO_TLSv1_3 # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_SINGLE_DH_USE # header: /usr/include/openssl/ssl.h
---include-constant SSL_OP_SINGLE_ECDH_USE # header: /usr/include/openssl/ssl.h
---include-constant SSL_RECEIVED_SHUTDOWN # header: /usr/include/openssl/ssl.h
---include-constant SSL_SENT_SHUTDOWN # header: /usr/include/openssl/ssl.h
---include-constant SSL_SESS_CACHE_OFF # header: /usr/include/openssl/ssl.h
---include-constant SSL_SESS_CACHE_SERVER # header: /usr/include/openssl/ssl.h
---include-constant SSL_VERIFY_FAIL_IF_NO_PEER_CERT # header: /usr/include/openssl/ssl.h
---include-constant SSL_VERIFY_NONE # header: /usr/include/openssl/ssl.h
---include-constant SSL_VERIFY_PEER # header: /usr/include/openssl/ssl.h
-
-#### Extracted from: /usr/include/openssl/ssl2.h
-
---include-constant SSL2_VERSION # header: /usr/include/openssl/ssl2.h
-
-#### Extracted from: /usr/include/openssl/ssl3.h
-
---include-constant SSL3_VERSION # header: /usr/include/openssl/ssl3.h
-
-#### Extracted from: /usr/include/openssl/tls1.h
-
---include-constant SSL_TLSEXT_ERR_NOACK # header: /usr/include/openssl/tls1.h
---include-constant SSL_TLSEXT_ERR_OK # header: /usr/include/openssl/tls1.h
---include-constant TLS1_1_VERSION # header: /usr/include/openssl/tls1.h
---include-constant TLS1_2_VERSION # header: /usr/include/openssl/tls1.h
---include-constant TLS1_3_VERSION # header: /usr/include/openssl/tls1.h
---include-constant TLS1_VERSION # header: /usr/include/openssl/tls1.h
-
-#### Extracted from: /usr/include/openssl/stack.h
-
---include-function OPENSSL_sk_num # header: /usr/include/openssl/stack.h
---include-function OPENSSL_sk_value # header: /usr/include/openssl/stack.h
-
-#### Extracted from: /usr/include/openssl/x509.h
-
---include-function i2d_X509 # header: /usr/include/openssl/x509.h
---include-function d2i_X509 # header: /usr/include/openssl/x509.h
---include-function d2i_X509_bio # header: /usr/include/openssl/x509.h
---include-function X509_EXTENSION_get_data # header: /usr/include/openssl/x509.h
---include-function X509_free # header: /usr/include/openssl/x509.h
---include-function X509_get_ext # header: /usr/include/openssl/x509.h
---include-function X509_get_ext_by_NID # header: /usr/include/openssl/x509.h
---include-constant X509_FILETYPE_PEM # header: /usr/include/openssl/x509.h
-
-#### Extracted from: /usr/include/openssl/x509v3.h
-
---include-function X509_check_issued # header: /usr/include/openssl/x509v3.h
-
-#### Extracted from: /usr/include/openssl/x509_vfy.h
-
---include-function X509_LOOKUP_ctrl # header: /usr/include/openssl/x509_vfy.h
---include-function X509_LOOKUP_file # header: /usr/include/openssl/x509_vfy.h
---include-function X509_LOOKUP_hash_dir # header: /usr/include/openssl/x509_vfy.h
---include-function X509_STORE_add_lookup # header: /usr/include/openssl/x509_vfy.h
---include-function X509_STORE_CTX_get_current_cert # header: /usr/include/openssl/x509_vfy.h
---include-function X509_STORE_CTX_get_error # header: /usr/include/openssl/x509_vfy.h
---include-function X509_STORE_CTX_get_error_depth # header: /usr/include/openssl/x509_vfy.h
---include-function X509_STORE_CTX_get_ex_data # header: /usr/include/openssl/x509_vfy.h
---include-function X509_STORE_CTX_get0_current_issuer # header: /usr/include/openssl/x509_vfy.h
---include-function X509_STORE_CTX_get0_untrusted # header: /usr/include/openssl/x509_vfy.h
---include-function X509_STORE_CTX_set_error # header: /usr/include/openssl/x509_vfy.h
---include-function X509_STORE_set_flags # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_L_ADD_DIR # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_L_FILE_LOAD # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_ERR_APPLICATION_VERIFICATION # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_ERR_CERT_UNTRUSTED # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_ERR_CRL_HAS_EXPIRED # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_FLAG_CRL_CHECK # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_FLAG_CRL_CHECK_ALL # header: /usr/include/openssl/x509_vfy.h
---include-constant X509_V_OK # header: /usr/include/openssl/x509_vfy.h
-
diff --git a/modules/openssl-foreign/openssl.h b/modules/openssl-foreign/openssl.h
deleted file mode 100644
index e31fad9e1b..0000000000
--- a/modules/openssl-foreign/openssl.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <openssl/opensslv.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/pkcs12.h>
-#include <openssl/crypto.h>
-#include <openssl/evp.h>
-#include <openssl/rand.h>
-#include <openssl/x509v3.h>
-#include <openssl/dh.h>
-#include <openssl/bn.h>
-#include <openssl/engine.h>
-#include <openssl/ocsp.h>
-#include <openssl/provider.h>
diff --git a/modules/openssl-foreign/pom.xml b/modules/openssl-foreign/pom.xml
deleted file mode 100644
index f27b1cba4a..0000000000
--- a/modules/openssl-foreign/pom.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache</groupId>
- <artifactId>apache</artifactId>
- <version>30</version>
- </parent>
-
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-coyote-openssl</artifactId>
- <name>Apache Tomcat OpenSSL support for Java 22</name>
- <description>OpenSSL support using FFM API included in Java 22</description>
- <version>0.1-SNAPSHOT</version>
-
- <properties>
- <tomcat.version>11.0.0-M22</tomcat.version>
- <project.build.outputTimestamp>2021-12-02T12:00:00Z</project.build.outputTimestamp>
- </properties>
-
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/tomcat.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/tomcat.git</developerConnection>
- <url>https://gitbox.apache.org/repos/asf?p=tomcat.git</url>
- <tag>HEAD</tag>
- </scm>
-
- <mailingLists>
- <mailingList>
- <name>Development List</name>
- <subscribe>dev-subscribe@tomcat.apache.org</subscribe>
- <unsubscribe>dev-unsubscribe@tomcat.apache.org</unsubscribe>
- <post>dev@tomcat.apache.org</post>
- </mailingList>
- <mailingList>
- <name>Users List</name>
- <subscribe>users-subscribe@tomcat.apache.org</subscribe>
- <unsubscribe>users-unsubscribe@tomcat.apache.org</unsubscribe>
- <post>users@tomcat.apache.org</post>
- </mailingList>
- </mailingLists>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-catalina</artifactId>
- <version>${tomcat.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-coyote</artifactId>
- <version>${tomcat.version}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <release>22</release>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <source>22</source>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java
deleted file mode 100644
index ec17de48ac..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java
+++ /dev/null
@@ -1,1422 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.foreign.Arena;
-import java.lang.foreign.MemorySegment;
-import java.lang.foreign.ValueLayout;
-import java.lang.ref.Cleaner;
-import java.lang.ref.Cleaner.Cleanable;
-import java.nio.charset.StandardCharsets;
-import java.security.SecureRandom;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Base64;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLParameters;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSessionContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509KeyManager;
-import javax.net.ssl.X509TrustManager;
-
-import static org.apache.tomcat.util.openssl.openssl_h.*;
-import static org.apache.tomcat.util.openssl.openssl_h_Compatibility.*;
-import static org.apache.tomcat.util.openssl.openssl_h_Macros.*;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.file.ConfigFileLoader;
-import org.apache.tomcat.util.file.ConfigurationSource.Resource;
-import org.apache.tomcat.util.net.Constants;
-import org.apache.tomcat.util.net.SSLHostConfig;
-import org.apache.tomcat.util.net.SSLHostConfig.CertificateVerification;
-import org.apache.tomcat.util.net.SSLHostConfigCertificate;
-import org.apache.tomcat.util.net.SSLHostConfigCertificate.Type;
-import org.apache.tomcat.util.net.openssl.OpenSSLConf;
-import org.apache.tomcat.util.net.openssl.OpenSSLConfCmd;
-import org.apache.tomcat.util.net.openssl.OpenSSLUtil;
-import org.apache.tomcat.util.openssl.SSL_CTX_set_alpn_select_cb$cb;
-import org.apache.tomcat.util.openssl.SSL_CTX_set_cert_verify_callback$cb;
-import org.apache.tomcat.util.openssl.SSL_CTX_set_tmp_dh_callback$dh;
-import org.apache.tomcat.util.openssl.SSL_CTX_set_verify$callback;
-import org.apache.tomcat.util.openssl.pem_password_cb;
-import org.apache.tomcat.util.res.StringManager;
-
-public class OpenSSLContext implements org.apache.tomcat.util.net.SSLContext {
-
- private static final Log log = LogFactory.getLog(OpenSSLContext.class);
- private static final StringManager sm = StringManager.getManager(OpenSSLContext.class);
-
- private static final Cleaner cleaner = Cleaner.create();
-
- private static final int OPENSSL_ERROR_MESSAGE_BUFFER_SIZE = 256;
-
- private static final String defaultProtocol = "TLS";
-
- private static final int SSL_AIDX_RSA = 0;
- private static final int SSL_AIDX_DSA = 1;
- private static final int SSL_AIDX_ECC = 3;
- private static final int SSL_AIDX_MAX = 4;
-
- public static final int SSL_PROTOCOL_NONE = 0;
- public static final int SSL_PROTOCOL_SSLV2 = (1<<0);
- public static final int SSL_PROTOCOL_SSLV3 = (1<<1);
- public static final int SSL_PROTOCOL_TLSV1 = (1<<2);
- public static final int SSL_PROTOCOL_TLSV1_1 = (1<<3);
- public static final int SSL_PROTOCOL_TLSV1_2 = (1<<4);
- public static final int SSL_PROTOCOL_TLSV1_3 = (1<<5);
- public static final int SSL_PROTOCOL_ALL = (SSL_PROTOCOL_TLSV1 | SSL_PROTOCOL_TLSV1_1 | SSL_PROTOCOL_TLSV1_2 |
- SSL_PROTOCOL_TLSV1_3);
-
- static final int OPTIONAL_NO_CA = 3;
-
- private static final String BEGIN_KEY = "-----BEGIN PRIVATE KEY-----\n";
- private static final Object END_KEY = "\n-----END PRIVATE KEY-----";
-
- private static final byte[] HTTP_11_PROTOCOL =
- new byte[] { 'h', 't', 't', 'p', '/', '1', '.', '1' };
-
- private static final byte[] DEFAULT_SESSION_ID_CONTEXT =
- new byte[] { 'd', 'e', 'f', 'a', 'u', 'l', 't' };
-
- static final CertificateFactory X509_CERT_FACTORY;
- static {
- try {
- X509_CERT_FACTORY = CertificateFactory.getInstance("X.509");
- } catch (CertificateException e) {
- throw new IllegalStateException(sm.getString("openssl.X509FactoryError"), e);
- }
- }
-
- static final boolean OPENSSL_3 = (OpenSSL_version_num() >= 0x3000000fL);
-
- private final SSLHostConfig sslHostConfig;
- private final SSLHostConfigCertificate certificate;
- private final boolean alpn;
- private final int minTlsVersion;
- private final int maxTlsVersion;
- private final List<byte[]> negotiableProtocols;
-
- private OpenSSLSessionContext sessionContext;
- private String enabledProtocol;
- private boolean initialized = false;
-
- private boolean noOcspCheck = false;
- private X509TrustManager x509TrustManager;
-
- private final ContextState state;
- private final Arena contextArena;
- private final Cleanable cleanable;
-
- private static String[] getCiphers(MemorySegment sslCtx) {
- MemorySegment sk = SSL_CTX_get_ciphers(sslCtx);
- int len = OPENSSL_sk_num(sk);
- if (len <= 0) {
- return null;
- }
- ArrayList<String> ciphers = new ArrayList<>(len);
- for (int i = 0; i < len; i++) {
- MemorySegment cipher = OPENSSL_sk_value(sk, i);
- MemorySegment cipherName = SSL_CIPHER_get_name(cipher);
- ciphers.add(cipherName.getString(0));
- }
- return ciphers.toArray(new String[0]);
- }
-
- public OpenSSLContext(SSLHostConfigCertificate certificate, List<String> negotiableProtocols)
- throws SSLException {
-
- // Check that OpenSSL was initialized
- if (!OpenSSLStatus.isInitialized()) {
- try {
- OpenSSLLibrary.init();
- } catch (Exception e) {
- throw new SSLException(e);
- }
- }
-
- this.sslHostConfig = certificate.getSSLHostConfig();
- this.certificate = certificate;
- contextArena = Arena.ofAuto();
-
- MemorySegment sslCtx = MemorySegment.NULL;
- MemorySegment confCtx = MemorySegment.NULL;
- List<byte[]> negotiableProtocolsBytes = null;
- boolean success = false;
- try {
- // Create OpenSSLConfCmd context if used
- OpenSSLConf openSslConf = sslHostConfig.getOpenSslConf();
- if (openSslConf != null) {
- if (log.isTraceEnabled()) {
- log.trace(sm.getString("openssl.makeConf"));
- }
- confCtx = SSL_CONF_CTX_new();
- if (MemorySegment.NULL.equals(confCtx)) {
- throw new SSLException(sm.getString("openssl.errMakeConf", getLastError()));
- }
- SSL_CONF_CTX_set_flags(confCtx, SSL_CONF_FLAG_FILE() |
- SSL_CONF_FLAG_SERVER() |
- SSL_CONF_FLAG_CERTIFICATE() |
- SSL_CONF_FLAG_SHOW_ERRORS());
- }
-
- // SSL protocol
- sslCtx = SSL_CTX_new(TLS_server_method());
-
- int protocol = SSL_PROTOCOL_NONE;
- for (String enabledProtocol : sslHostConfig.getEnabledProtocols()) {
- if (Constants.SSL_PROTO_SSLv2Hello.equalsIgnoreCase(enabledProtocol)) {
- // NO-OP. OpenSSL always supports SSLv2Hello
- } else if (Constants.SSL_PROTO_SSLv2.equalsIgnoreCase(enabledProtocol)) {
- protocol |= SSL_PROTOCOL_SSLV2;
- } else if (Constants.SSL_PROTO_SSLv3.equalsIgnoreCase(enabledProtocol)) {
- protocol |= SSL_PROTOCOL_SSLV3;
- } else if (Constants.SSL_PROTO_TLSv1.equalsIgnoreCase(enabledProtocol)) {
- protocol |= SSL_PROTOCOL_TLSV1;
- } else if (Constants.SSL_PROTO_TLSv1_1.equalsIgnoreCase(enabledProtocol)) {
- protocol |= SSL_PROTOCOL_TLSV1_1;
- } else if (Constants.SSL_PROTO_TLSv1_2.equalsIgnoreCase(enabledProtocol)) {
- protocol |= SSL_PROTOCOL_TLSV1_2;
- } else if (Constants.SSL_PROTO_TLSv1_3.equalsIgnoreCase(enabledProtocol)) {
- protocol |= SSL_PROTOCOL_TLSV1_3;
- } else if (Constants.SSL_PROTO_ALL.equalsIgnoreCase(enabledProtocol)) {
- protocol |= SSL_PROTOCOL_ALL;
- } else {
- // Should not happen since filtering to build
- // enabled protocols removes invalid values.
- throw new Exception(sm.getString("openssl.invalidSslProtocol", enabledProtocol));
- }
- }
- // Set maximum and minimum protocol versions
- int prot = SSL2_VERSION();
- if ((protocol & SSL_PROTOCOL_TLSV1_3) > 0) {
- prot = TLS1_3_VERSION();
- } else if ((protocol & SSL_PROTOCOL_TLSV1_2) > 0) {
- prot = TLS1_2_VERSION();
- } else if ((protocol & SSL_PROTOCOL_TLSV1_1) > 0) {
- prot = TLS1_1_VERSION();
- } else if ((protocol & SSL_PROTOCOL_TLSV1) > 0) {
- prot = TLS1_VERSION();
- } else if ((protocol & SSL_PROTOCOL_SSLV3) > 0) {
- prot = SSL3_VERSION();
- }
- maxTlsVersion = prot;
- SSL_CTX_set_max_proto_version(sslCtx, prot);
- if (prot == TLS1_3_VERSION() && (protocol & SSL_PROTOCOL_TLSV1_2) > 0) {
- prot = TLS1_2_VERSION();
- }
- if (prot == TLS1_2_VERSION() && (protocol & SSL_PROTOCOL_TLSV1_1) > 0) {
- prot = TLS1_1_VERSION();
- }
- if (prot == TLS1_1_VERSION() && (protocol & SSL_PROTOCOL_TLSV1) > 0) {
- prot = TLS1_VERSION();
- }
- if (prot == TLS1_VERSION() && (protocol & SSL_PROTOCOL_SSLV3) > 0) {
- prot = SSL3_VERSION();
- }
- minTlsVersion = prot;
- SSL_CTX_set_min_proto_version(sslCtx, prot);
-
- // Disable compression, usually unsafe
- SSL_CTX_set_options(sslCtx, SSL_OP_NO_COMPRESSION());
-
- // Disallow a session from being resumed during a renegotiation,
- // so that an acceptable cipher suite can be negotiated.
- SSL_CTX_set_options(sslCtx, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION());
-
- SSL_CTX_set_options(sslCtx, SSL_OP_SINGLE_DH_USE());
- SSL_CTX_set_options(sslCtx, SSL_OP_SINGLE_ECDH_USE());
-
- // Default session context id and cache size
- SSL_CTX_sess_set_cache_size(sslCtx, 256);
-
- // Session cache is disabled by default
- SSL_CTX_set_session_cache_mode(sslCtx, SSL_SESS_CACHE_OFF());
-
- // Longer session timeout
- SSL_CTX_set_timeout(sslCtx, 14400);
-
- // Set int pem_password_cb(char *buf, int size, int rwflag, void *u) callback
- SSL_CTX_set_default_passwd_cb(sslCtx,
- pem_password_cb.allocate(new PasswordCallback(null), contextArena));
-
- if (negotiableProtocols != null && negotiableProtocols.size() > 0) {
- alpn = true;
- negotiableProtocolsBytes = new ArrayList<>(negotiableProtocols.size() + 1);
- for (String negotiableProtocol : negotiableProtocols) {
- negotiableProtocolsBytes.add(negotiableProtocol.getBytes(StandardCharsets.ISO_8859_1));
- }
- negotiableProtocolsBytes.add(HTTP_11_PROTOCOL);
- } else {
- alpn = false;
- }
-
- success = true;
- } catch(Exception e) {
- throw new SSLException(sm.getString("openssl.errorSSLCtxInit"), e);
- } finally {
- this.negotiableProtocols = negotiableProtocolsBytes;
- state = new ContextState(sslCtx, confCtx);
- /*
- * When an SSLHostConfig is replaced at runtime, it is not possible to
- * call destroy() on the associated OpenSSLContext since it is likely
- * that there will be in-progress connections using the OpenSSLContext.
- * A reference chain has been deliberately established (see
- * OpenSSLSessionContext) to ensure that the OpenSSLContext remains
- * ineligible for GC while those connections are alive. Once those
- * connections complete, the OpenSSLContext will become eligible for GC
- * and the memory session will ensure that the associated native
- * resources are cleaned up.
- */
- cleanable = cleaner.register(this, state);
-
- if (!success) {
- destroy();
- }
- }
- }
-
-
- public String getEnabledProtocol() {
- return enabledProtocol;
- }
-
-
- public void setEnabledProtocol(String protocol) {
- enabledProtocol = (protocol == null) ? defaultProtocol : protocol;
- }
-
-
- @Override
- public void destroy() {
- cleanable.clean();
- }
-
-
- private boolean checkConf(OpenSSLConf conf) throws Exception {
- boolean result = true;
- OpenSSLConfCmd cmd;
- String name;
- String value;
- int rc;
- for (OpenSSLConfCmd command : conf.getCommands()) {
- cmd = command;
- name = cmd.getName();
- value = cmd.getValue();
- if (name == null) {
- log.error(sm.getString("opensslconf.noCommandName", value));
- result = false;
- continue;
- }
- if (log.isTraceEnabled()) {
- log.trace(sm.getString("opensslconf.checkCommand", name, value));
- }
- try (var localArena = Arena.ofConfined()) {
- if (name.equals("NO_OCSP_CHECK")) {
- rc = 1;
- } else {
- int code = SSL_CONF_cmd_value_type(state.confCtx, localArena.allocateFrom(name));
- rc = 1;
- String errorMessage = getLastError();
- if (errorMessage != null) {
- log.error(sm.getString("opensslconf.checkFailed", errorMessage));
- rc = 0;
- }
- if (code == SSL_CONF_TYPE_UNKNOWN()) {
- log.error(sm.getString("opensslconf.typeUnknown", name));
- rc = 0;
- }
- if (code == SSL_CONF_TYPE_FILE()) {
- // Check file
- File file = new File(value);
- if (!file.isFile() && !file.canRead()) {
- log.error(sm.getString("opensslconf.badFile", name, value));
- rc = 0;
- }
- }
- if (code == SSL_CONF_TYPE_DIR()) {
- // Check dir
- File file = new File(value);
- if (!file.isDirectory()) {
- log.error(sm.getString("opensslconf.badDirectory", name, value));
- rc = 0;
- }
- }
- }
- } catch (Exception e) {
- log.error(sm.getString("opensslconf.checkFailed", e.getLocalizedMessage()));
- return false;
- }
- if (rc <= 0) {
- log.error(sm.getString("opensslconf.failedCommand", name, value,
- Integer.toString(rc)));
- result = false;
- } else if (log.isTraceEnabled()) {
- log.trace(sm.getString("opensslconf.resultCommand", name, value,
- Integer.toString(rc)));
- }
- }
- if (!result) {
- log.error(sm.getString("opensslconf.checkFailed"));
- }
- return result;
- }
-
-
- private boolean applyConf(OpenSSLConf conf) throws Exception {
- boolean result = true;
- SSL_CONF_CTX_set_ssl_ctx(state.confCtx, state.sslCtx);
- OpenSSLConfCmd cmd;
- String name;
- String value;
- int rc;
- for (OpenSSLConfCmd command : conf.getCommands()) {
- cmd = command;
- name = cmd.getName();
- value = cmd.getValue();
- if (name == null) {
- log.error(sm.getString("opensslconf.noCommandName", value));
- result = false;
- continue;
- }
- if (log.isTraceEnabled()) {
- log.trace(sm.getString("opensslconf.applyCommand", name, value));
- }
- try (var localArena = Arena.ofConfined()) {
- if (name.equals("NO_OCSP_CHECK")) {
- noOcspCheck = Boolean.parseBoolean(value);
- rc = 1;
- } else {
- rc = SSL_CONF_cmd(state.confCtx, localArena.allocateFrom(name),
- localArena.allocateFrom(value));
- String errorMessage = getLastError();
- if (rc <= 0 || errorMessage != null) {
- log.error(sm.getString("opensslconf.commandError", name, value, errorMessage));
- rc = 0;
- }
- }
- } catch (Exception e) {
- log.error(sm.getString("opensslconf.applyFailed"));
- return false;
- }
- if (rc <= 0) {
- log.error(sm.getString("opensslconf.failedCommand", name, value,
- Integer.toString(rc)));
- result = false;
- } else if (log.isTraceEnabled()) {
- log.trace(sm.getString("opensslconf.resultCommand", name, value,
- Integer.toString(rc)));
- }
- }
- // rc = SSLConf.finish(confCtx);
- rc = SSL_CONF_CTX_finish(state.confCtx);
- if (rc <= 0) {
- log.error(sm.getString("opensslconf.finishFailed", Integer.toString(rc)));
- result = false;
- }
- if (!result) {
- log.error(sm.getString("opensslconf.applyFailed"));
- }
- return result;
- }
-
- /**
- * Setup the SSL_CTX.
- *
- * @param kms Must contain a KeyManager of the type
- * {@code OpenSSLKeyManager}
- * @param tms Must contain a TrustManager of the type
- * {@code X509TrustManager}
- * @param sr Is not used for this implementation.
- */
- @Override
- public void init(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) {
- if (initialized) {
- log.warn(sm.getString("openssl.doubleInit"));
- return;
- }
- boolean success = true;
- try (var localArena = Arena.ofConfined()) {
- if (sslHostConfig.getInsecureRenegotiation()) {
- SSL_CTX_set_options(state.sslCtx, SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION());
- } else {
- SSL_CTX_clear_options(state.sslCtx, SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION());
- }
-
- // Use server's preference order for ciphers (rather than
- // client's)
- if (sslHostConfig.getHonorCipherOrder()) {
- SSL_CTX_set_options(state.sslCtx, SSL_OP_CIPHER_SERVER_PREFERENCE());
- } else {
- SSL_CTX_clear_options(state.sslCtx, SSL_OP_CIPHER_SERVER_PREFERENCE());
- }
-
- // Disable compression if requested
- if (sslHostConfig.getDisableCompression()) {
- SSL_CTX_set_options(state.sslCtx, SSL_OP_NO_COMPRESSION());
- } else {
- SSL_CTX_clear_options(state.sslCtx, SSL_OP_NO_COMPRESSION());
- }
-
- // Disable TLS Session Tickets (RFC4507) to protect perfect forward secrecy
- if (sslHostConfig.getDisableSessionTickets()) {
- SSL_CTX_set_options(state.sslCtx, SSL_OP_NO_TICKET());
- } else {
- SSL_CTX_clear_options(state.sslCtx, SSL_OP_NO_TICKET());
- }
-
- // List the ciphers that the client is permitted to negotiate
- if (minTlsVersion <= TLS1_2_VERSION()) {
- if (SSL_CTX_set_cipher_list(state.sslCtx,
- localArena.allocateFrom(sslHostConfig.getCiphers())) <= 0) {
- log.warn(sm.getString("engine.failedCipherList", sslHostConfig.getCiphers()));
- }
- }
- if (maxTlsVersion >= TLS1_3_VERSION() && (sslHostConfig.getCiphers() != SSLHostConfig.DEFAULT_TLS_CIPHERS)) {
- if (SSL_CTX_set_ciphersuites(state.sslCtx,
- localArena.allocateFrom(sslHostConfig.getCiphers())) <= 0) {
- log.warn(sm.getString("engine.failedCipherSuite", sslHostConfig.getCiphers()));
- }
- }
-
- // If there is no certificate file must be using a KeyStore so a KeyManager is required.
- // If there is a certificate file a KeyManager is helpful but not strictly necessary.
- certificate.setCertificateKeyManager(
- OpenSSLUtil.chooseKeyManager(kms, certificate.getCertificateFile() == null));
-
- success = addCertificate(certificate, localArena);
-
- // Client certificate verification
- int value = 0;
- switch (sslHostConfig.getCertificateVerification()) {
- case NONE:
- value = SSL_VERIFY_NONE();
- break;
- case OPTIONAL:
- value = SSL_VERIFY_PEER();
- break;
- case OPTIONAL_NO_CA:
- value = OPTIONAL_NO_CA;
- break;
- case REQUIRED:
- value = SSL_VERIFY_FAIL_IF_NO_PEER_CERT();
- break;
- }
-
- // Set int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) callback
- SSL_CTX_set_verify(state.sslCtx, value,
- SSL_CTX_set_verify$callback.allocate(new OpenSSLEngine.VerifyCallback(), contextArena));
-
- // Trust and certificate verification
- if (tms != null) {
- // Client certificate verification based on custom trust managers
- x509TrustManager = chooseTrustManager(tms);
- SSL_CTX_set_cert_verify_callback(state.sslCtx,
- SSL_CTX_set_cert_verify_callback$cb.allocate(new CertVerifyCallback(x509TrustManager), contextArena), state.sslCtx);
-
- // Pass along the DER encoded certificates of the accepted client
- // certificate issuers, so that their subjects can be presented
- // by the server during the handshake to allow the client choosing
- // an acceptable certificate
- for (X509Certificate caCert : x509TrustManager.getAcceptedIssuers()) {
- var rawCACertificate = localArena.allocateFrom(ValueLayout.JAVA_BYTE, caCert.getEncoded());
- var rawCACertificatePointer = localArena.allocateFrom(ValueLayout.ADDRESS, rawCACertificate);
- var x509CACert = d2i_X509(MemorySegment.NULL, rawCACertificatePointer, rawCACertificate.byteSize());
- if (MemorySegment.NULL.equals(x509CACert)) {
- logLastError("openssl.errorLoadingCertificate");
- } else if (SSL_CTX_add_client_CA(state.sslCtx, x509CACert) <= 0) {
- logLastError("openssl.errorAddingCertificate");
- } else if (log.isDebugEnabled()) {
- log.debug(sm.getString("openssl.addedClientCaCert", caCert.toString()));
- }
- }
- } else {
- // Client certificate verification based on trusted CA files and dirs
- MemorySegment caCertificateFileNative = sslHostConfig.getCaCertificateFile() != null
- ? localArena.allocateFrom(SSLHostConfig.adjustRelativePath(sslHostConfig.getCaCertificateFile())) : MemorySegment.NULL;
- MemorySegment caCertificatePathNative = sslHostConfig.getCaCertificatePath() != null
- ? localArena.allocateFrom(SSLHostConfig.adjustRelativePath(sslHostConfig.getCaCertificatePath())) : MemorySegment.NULL;
- if ((sslHostConfig.getCaCertificateFile() != null || sslHostConfig.getCaCertificatePath() != null)
- && SSL_CTX_load_verify_locations(state.sslCtx,
- caCertificateFileNative, caCertificatePathNative) <= 0) {
- logLastError("openssl.errorConfiguringLocations");
- } else {
- var caCerts = SSL_CTX_get_client_CA_list(state.sslCtx);
- if (MemorySegment.NULL.equals(caCerts)) {
- caCerts = SSL_load_client_CA_file(caCertificateFileNative);
- if (!MemorySegment.NULL.equals(caCerts)) {
- SSL_CTX_set_client_CA_list(state.sslCtx, caCerts);
- }
- } else {
- // OpenSSL might crash here when passing null on some platforms
- if (MemorySegment.NULL.equals(caCertificateFileNative)
- || (SSL_add_file_cert_subjects_to_stack(caCerts, caCertificateFileNative) <= 0)) {
- caCerts = MemorySegment.NULL;
- }
- }
- if (MemorySegment.NULL.equals(caCerts)) {
- log.warn(sm.getString("openssl.noCACerts"));
- }
- }
- }
-
- if (negotiableProtocols != null && negotiableProtocols.size() > 0) {
- SSL_CTX_set_alpn_select_cb(state.sslCtx,
- SSL_CTX_set_alpn_select_cb$cb.allocate(new ALPNSelectCallback(negotiableProtocols), contextArena), state.sslCtx);
- }
-
- // Apply OpenSSLConfCmd if used
- OpenSSLConf openSslConf = sslHostConfig.getOpenSslConf();
- if (openSslConf != null && !MemorySegment.NULL.equals(state.confCtx)) {
- // Check OpenSSLConfCmd if used
- if (log.isTraceEnabled()) {
- log.trace(sm.getString("openssl.checkConf"));
- }
- try {
- if (!checkConf(openSslConf)) {
- log.error(sm.getString("openssl.errCheckConf"));
- }
- } catch (Exception e) {
- log.error(sm.getString("openssl.errCheckConf"), e);
- }
- if (log.isTraceEnabled()) {
- log.trace(sm.getString("openssl.applyConf"));
- }
- try {
- if (!applyConf(openSslConf)) {
- log.error(sm.getString("openssl.errApplyConf"));
- }
- } catch (Exception e) {
- log.error(sm.getString("openssl.errApplyConf"), e);
- }
- // Reconfigure the enabled protocols
- long opts = SSL_CTX_get_options(state.sslCtx);
- List<String> enabled = new ArrayList<>();
- // Seems like there is no way to explicitly disable SSLv2Hello
- // in OpenSSL so it is always enabled
- enabled.add(Constants.SSL_PROTO_SSLv2Hello);
- if ((opts & SSL_OP_NO_TLSv1()) == 0) {
- enabled.add(Constants.SSL_PROTO_TLSv1);
- }
- if ((opts & SSL_OP_NO_TLSv1_1()) == 0) {
- enabled.add(Constants.SSL_PROTO_TLSv1_1);
- }
- if ((opts & SSL_OP_NO_TLSv1_2()) == 0) {
- enabled.add(Constants.SSL_PROTO_TLSv1_2);
- }
- if ((opts & SSL_OP_NO_TLSv1_3()) == 0) {
- enabled.add(Constants.SSL_PROTO_TLSv1_3);
- }
- if ((opts & SSL_OP_NO_SSLv2()) == 0) {
- enabled.add(Constants.SSL_PROTO_SSLv2);
- }
- if ((opts & SSL_OP_NO_SSLv3()) == 0) {
- enabled.add(Constants.SSL_PROTO_SSLv3);
- }
- sslHostConfig.setEnabledProtocols(
- enabled.toArray(new String[0]));
- // Reconfigure the enabled ciphers
- sslHostConfig.setEnabledCiphers(getCiphers(state.sslCtx));
- }
-
- sessionContext = new OpenSSLSessionContext(this);
- // If client authentication is being used, OpenSSL requires that
- // this is set so always set it in case an app is configured to
- // require it
- sessionContext.setSessionIdContext(DEFAULT_SESSION_ID_CONTEXT);
- sslHostConfig.setOpenSslContext(Long.valueOf(state.sslCtx.address()));
- initialized = true;
- } catch (Exception e) {
- log.warn(sm.getString("openssl.errorSSLCtxInit"), e);
- success = false;
- }
- if (!success) {
- destroy();
- }
- }
-
-
- public MemorySegment getSSLContext() {
- return state.sslCtx;
- }
-
- // DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength)
- private static class TmpDHCallback implements SSL_CTX_set_tmp_dh_callback$dh.Function {
- @Override
- public MemorySegment apply(MemorySegment ssl, int isExport, int keylength) {
- var pkey = SSL_get_privatekey(ssl);
- int type = (MemorySegment.NULL.equals(pkey)) ? EVP_PKEY_NONE() : EVP_PKEY_base_id(pkey);
- /*
- * OpenSSL will call us with either keylen == 512 or keylen == 1024
- * (see the definition of SSL_EXPORT_PKEYLENGTH in ssl_locl.h).
- * Adjust the DH parameter length according to the size of the
- * RSA/DSA private key used for the current connection, and always
- * use at least 1024-bit parameters.
- * Note: This may cause interoperability issues with implementations
- * which limit their DH support to 1024 bit - e.g. Java 7 and earlier.
- * In this case, SSLCertificateFile can be used to specify fixed
- * 1024-bit DH parameters (with the effect that OpenSSL skips this
- * callback).
- */
- int keylen = 0;
- if (type == EVP_PKEY_RSA() || type == EVP_PKEY_DSA()) {
- keylen = EVP_PKEY_bits(pkey);
- }
- for (int i = 0; i < OpenSSLLibrary.dhParameters.length; i++) {
- if (keylen >= OpenSSLLibrary.dhParameters[i].min) {
- return OpenSSLLibrary.dhParameters[i].dh;
- }
- }
- return MemorySegment.NULL;
- }
- }
-
- // int SSL_callback_alpn_select_proto(SSL* ssl, const unsigned char **out, unsigned char *outlen,
- // const unsigned char *in, unsigned int inlen, void *arg)
- private static class ALPNSelectCallback implements SSL_CTX_set_alpn_select_cb$cb.Function {
- private final List<byte[]> negotiableProtocols;
- ALPNSelectCallback(List<byte[]> negotiableProtocols) {
- this.negotiableProtocols = negotiableProtocols;
- }
- @Override
- public int apply(MemorySegment ssl, MemorySegment out,
- MemorySegment outlen, MemorySegment in, int inlen, MemorySegment arg) {
- try (var localArena = Arena.ofConfined()) {
- MemorySegment inSeg = in.reinterpret(inlen, localArena, null);
- byte[] advertisedBytes = inSeg.toArray(ValueLayout.JAVA_BYTE);
- for (byte[] negotiableProtocolBytes : negotiableProtocols) {
- for (int i = 0; i <= advertisedBytes.length - negotiableProtocolBytes.length; i++) {
- if (advertisedBytes[i] == negotiableProtocolBytes[0]) {
- for (int j = 0; j < negotiableProtocolBytes.length; j++) {
- if (advertisedBytes[i + j] == negotiableProtocolBytes[j]) {
- if (j == negotiableProtocolBytes.length - 1) {
- // Match
- MemorySegment outSeg = out.reinterpret(ValueLayout.ADDRESS.byteSize(), localArena, null);
- outSeg.set(ValueLayout.ADDRESS, 0, inSeg.asSlice(i));
- MemorySegment outlenSeg = outlen.reinterpret(ValueLayout.JAVA_BYTE.byteSize(), localArena, null);
- outlenSeg.set(ValueLayout.JAVA_BYTE, 0, (byte) negotiableProtocolBytes.length);
- return SSL_TLSEXT_ERR_OK();
- }
- } else {
- break;
- }
- }
- }
- }
- }
- }
- return SSL_TLSEXT_ERR_NOACK();
- }
- }
-
-
- private static class CertVerifyCallback implements SSL_CTX_set_cert_verify_callback$cb.Function {
- private final X509TrustManager x509TrustManager;
- CertVerifyCallback(X509TrustManager x509TrustManager) {
- this.x509TrustManager = x509TrustManager;
- }
- @Override
- public int apply(MemorySegment /*X509_STORE_CTX*/ x509_ctx, MemorySegment param) {
- if (log.isTraceEnabled()) {
- log.trace("Certificate verification");
- }
- if (MemorySegment.NULL.equals(param)) {
- return 0;
- }
- MemorySegment ssl = X509_STORE_CTX_get_ex_data(x509_ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
- MemorySegment /*STACK_OF(X509)*/ sk = X509_STORE_CTX_get0_untrusted(x509_ctx);
- int len = OPENSSL_sk_num(sk);
- byte[][] certificateChain = new byte[len][];
- try (var localArena = Arena.ofConfined()) {
- for (int i = 0; i < len; i++) {
- MemorySegment/*(X509*)*/ x509 = OPENSSL_sk_value(sk, i);
- MemorySegment bufPointer = localArena.allocateFrom(ValueLayout.ADDRESS, MemorySegment.NULL);
- int length = i2d_X509(x509, bufPointer);
- if (length < 0) {
- certificateChain[i] = new byte[0];
- continue;
- }
- MemorySegment buf = bufPointer.get(ValueLayout.ADDRESS, 0);
- certificateChain[i] = buf.reinterpret(length, localArena, null).toArray(ValueLayout.JAVA_BYTE);
- OPENSSL_free(buf);
- }
- MemorySegment cipher = SSL_get_current_cipher(ssl);
- String authMethod = (MemorySegment.NULL.equals(cipher)) ? "UNKNOWN"
- : getCipherAuthenticationMethod(SSL_CIPHER_get_auth_nid(cipher), SSL_CIPHER_get_kx_nid(cipher));
- X509Certificate[] peerCerts = certificates(certificateChain);
- try {
- x509TrustManager.checkClientTrusted(peerCerts, authMethod);
- return 1;
- } catch (Exception e) {
- log.debug(sm.getString("openssl.certificateVerificationFailed"), e);
- }
- }
- return 0;
- }
- }
-
- private static final int NID_kx_rsa = 1037/*NID_kx_rsa()*/;
- //private static final int NID_kx_dhe = NID_kx_dhe();
- //private static final int NID_kx_ecdhe = NID_kx_ecdhe();
-
- //private static final int NID_auth_rsa = NID_auth_rsa();
- //private static final int NID_auth_dss = NID_auth_dss();
- //private static final int NID_auth_null = NID_auth_null();
- //private static final int NID_auth_ecdsa = NID_auth_ecdsa();
-
- //private static final int SSL_kRSA = 1;
- private static final int SSL_kDHr = 2;
- private static final int SSL_kDHd = 4;
- private static final int SSL_kEDH = 8;
- private static final int SSL_kDHE = SSL_kEDH;
- private static final int SSL_kKRB5 = 10;
- private static final int SSL_kECDHr = 20;
- private static final int SSL_kECDHe = 40;
- private static final int SSL_kEECDH = 80;
- private static final int SSL_kECDHE = SSL_kEECDH;
- //private static final int SSL_kPSK = 100;
- //private static final int SSL_kGOST = 200;
- //private static final int SSL_kSRP = 400;
-
- private static final int SSL_aRSA = 1;
- private static final int SSL_aDSS = 2;
- private static final int SSL_aNULL = 4;
- //private static final int SSL_aDH = 8;
- //private static final int SSL_aECDH = 10;
- //private static final int SSL_aKRB5 = 20;
- private static final int SSL_aECDSA = 40;
- //private static final int SSL_aPSK = 80;
- //private static final int SSL_aGOST94 = 100;
- //private static final int SSL_aGOST01 = 200;
- //private static final int SSL_aSRP = 400;
-
- private static final String SSL_TXT_RSA = "RSA";
- private static final String SSL_TXT_DH = "DH";
- private static final String SSL_TXT_DSS = "DSS";
- private static final String SSL_TXT_KRB5 = "KRB5";
- private static final String SSL_TXT_ECDH = "ECDH";
- private static final String SSL_TXT_ECDSA = "ECDSA";
-
- private static String getCipherAuthenticationMethod(int auth, int kx) {
- switch (kx) {
- case NID_kx_rsa:
- return SSL_TXT_RSA;
- case SSL_kDHr:
- return SSL_TXT_DH + "_" + SSL_TXT_RSA;
- case SSL_kDHd:
- return SSL_TXT_DH + "_" + SSL_TXT_DSS;
- case SSL_kDHE:
- switch (auth) {
- case SSL_aDSS:
- return "DHE_" + SSL_TXT_DSS;
- case SSL_aRSA:
- return "DHE_" + SSL_TXT_RSA;
- case SSL_aNULL:
- return SSL_TXT_DH + "_anon";
- default:
- return "UNKNOWN";
- }
- case SSL_kKRB5:
- return SSL_TXT_KRB5;
- case SSL_kECDHr:
- return SSL_TXT_ECDH + "_" + SSL_TXT_RSA;
- case SSL_kECDHe:
- return SSL_TXT_ECDH + "_" + SSL_TXT_ECDSA;
- case SSL_kECDHE:
- switch (auth) {
- case SSL_aECDSA:
- return "ECDHE_" + SSL_TXT_ECDSA;
- case SSL_aRSA:
- return "ECDHE_" + SSL_TXT_RSA;
- case SSL_aNULL:
- return SSL_TXT_ECDH + "_anon";
- default:
- return "UNKNOWN";
- }
- default:
- return "UNKNOWN";
- }
- }
-
- private static class PasswordCallback implements pem_password_cb.Function {
- private final String callbackPassword;
- PasswordCallback(String callbackPassword) {
- this.callbackPassword = callbackPassword;
- }
- @Override
- public int apply(MemorySegment /* char **/ buf, int bufsiz, int verify, MemorySegment /* void **/ cb) {
- if (log.isTraceEnabled()) {
- log.trace("Return password for certificate");
- }
- if (callbackPassword != null && callbackPassword.length() > 0) {
- try (var localArena = Arena.ofConfined()) {
- MemorySegment callbackPasswordNative = localArena.allocateFrom(callbackPassword);
- if (callbackPasswordNative.byteSize() > bufsiz) {
- // The password is too long
- log.error(sm.getString("openssl.passwordTooLong"));
- } else {
- MemorySegment bufSegment = buf.reinterpret(bufsiz, localArena, null);
- bufSegment.copyFrom(callbackPasswordNative);
- return (int) callbackPasswordNative.byteSize();
- }
- }
- }
- return 0;
- }
- }
-
-
- private boolean addCertificate(SSLHostConfigCertificate certificate, Arena localArena) throws Exception {
- int index = getCertificateIndex(certificate);
- // Load Server key and certificate
- if (certificate.getCertificateFile() != null) {
- // Pick right key password
- String keyPassToUse = null;
- String keyPass = certificate.getCertificateKeyPassword();
- if (keyPass == null) {
- keyPass = certificate.getCertificateKeystorePassword();
- }
- String keyPassFile = certificate.getCertificateKeyPasswordFile();
- if (keyPassFile == null) {
- keyPassFile = certificate.getCertificateKeystorePasswordFile();
- }
- if (keyPassFile != null) {
- try (BufferedReader reader =
- new BufferedReader(new InputStreamReader(
- ConfigFileLoader.getSource().getResource(keyPassFile).getInputStream(),
- StandardCharsets.UTF_8))) {
- keyPassToUse = reader.readLine();
- } catch (IOException e) {
- log.error(sm.getString("openssl.errorLoadingPassword", keyPassFile), e);
- return false;
- }
- } else {
- keyPassToUse = keyPass;
- }
- // Set certificate
- byte[] certificateFileBytes = null;
- try (Resource resource = ConfigFileLoader.getSource().getResource(certificate.getCertificateFile())) {
- certificateFileBytes = resource.getInputStream().readAllBytes();
- } catch (IOException e) {
- log.error(sm.getString("openssl.errorLoadingCertificate", certificate.getCertificateFile()), e);
- return false;
- }
- MemorySegment certificateFileBytesNative = localArena.allocateFrom(ValueLayout.JAVA_BYTE, certificateFileBytes);
- MemorySegment certificateBIO = BIO_new(BIO_s_mem());
- try {
- if (BIO_write(certificateBIO, certificateFileBytesNative, certificateFileBytes.length) <= 0) {
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificate.getCertificateFile(), getLastError()));
- return false;
- }
- MemorySegment cert = MemorySegment.NULL;
- MemorySegment key = MemorySegment.NULL;
- if (certificate.getCertificateFile().endsWith(".pkcs12")) {
- // Load pkcs12
- MemorySegment p12 = d2i_PKCS12_bio(certificateBIO, MemorySegment.NULL);
- if (MemorySegment.NULL.equals(p12)) {
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificate.getCertificateFile(), getLastError()));
- return false;
- }
- MemorySegment passwordAddress = MemorySegment.NULL;
- int passwordLength = 0;
- if (keyPassToUse != null && keyPassToUse.length() > 0) {
- passwordAddress = localArena.allocateFrom(keyPassToUse);
- passwordLength = (int) (passwordAddress.byteSize() - 1);
- }
- if (PKCS12_verify_mac(p12, passwordAddress, passwordLength) <= 0) {
- // Bad password
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificate.getCertificateFile(), getLastError()));
- PKCS12_free(p12);
- return false;
- }
- MemorySegment certPointer = localArena.allocate(ValueLayout.ADDRESS);
- MemorySegment keyPointer = localArena.allocate(ValueLayout.ADDRESS);
- if (PKCS12_parse(p12, passwordAddress, keyPointer, certPointer, MemorySegment.NULL) <= 0) {
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificate.getCertificateFile(), getLastError()));
- PKCS12_free(p12);
- return false;
- }
- PKCS12_free(p12);
- cert = certPointer.get(ValueLayout.ADDRESS, 0);
- key = keyPointer.get(ValueLayout.ADDRESS, 0);
- } else {
- String certificateKeyFileName = (certificate.getCertificateKeyFile() == null)
- ? certificate.getCertificateFile() : certificate.getCertificateKeyFile();
- // Load key
- byte[] certificateKeyFileBytes = null;
- try (Resource resource = ConfigFileLoader.getSource().getResource(certificateKeyFileName)) {
- certificateKeyFileBytes = resource.getInputStream().readAllBytes();
- } catch (IOException e) {
- log.error(sm.getString("openssl.errorLoadingCertificate", certificateKeyFileName), e);
- return false;
- }
- MemorySegment certificateKeyFileBytesNative = localArena.allocateFrom(ValueLayout.JAVA_BYTE, certificateKeyFileBytes);
- MemorySegment keyBIO = BIO_new(BIO_s_mem());
- try {
- if (BIO_write(keyBIO, certificateKeyFileBytesNative, certificateKeyFileBytes.length) <= 0) {
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificateKeyFileName, getLastError()));
- return false;
- }
- key = MemorySegment.NULL;
- for (int i = 0; i < 3; i++) {
- key = PEM_read_bio_PrivateKey(keyBIO, MemorySegment.NULL,
- pem_password_cb.allocate(new PasswordCallback(keyPassToUse), contextArena),
- MemorySegment.NULL);
- if (!MemorySegment.NULL.equals(key)) {
- break;
- }
- BIO_reset(keyBIO);
- }
- } finally {
- BIO_free(keyBIO);
- }
- if (MemorySegment.NULL.equals(key)) {
- if (!MemorySegment.NULL.equals(OpenSSLLibrary.enginePointer)) {
- // This needs a real file
- key = ENGINE_load_private_key(OpenSSLLibrary.enginePointer,
- localArena.allocateFrom(SSLHostConfig.adjustRelativePath(certificateKeyFileName)),
- MemorySegment.NULL, MemorySegment.NULL);
- }
- }
- if (MemorySegment.NULL.equals(key)) {
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificateKeyFileName, getLastError()));
- return false;
- }
- // Load certificate
- cert = PEM_read_bio_X509_AUX(certificateBIO, MemorySegment.NULL,
- pem_password_cb.allocate(new PasswordCallback(keyPassToUse), contextArena),
- MemorySegment.NULL);
- if (MemorySegment.NULL.equals(cert) &&
- // EOF is accepted, then try again
- ((ERR_peek_last_error() & ERR_REASON_MASK()) == PEM_R_NO_START_LINE())) {
- ERR_clear_error();
- BIO_reset(certificateBIO);
- cert = d2i_X509_bio(certificateBIO, MemorySegment.NULL);
- }
- if (MemorySegment.NULL.equals(cert)) {
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificate.getCertificateFile(), getLastError()));
- return false;
- }
- }
- if (SSL_CTX_use_certificate(state.sslCtx, cert) <= 0) {
- logLastError("openssl.errorLoadingCertificate");
- return false;
- }
- if (SSL_CTX_use_PrivateKey(state.sslCtx, key) <= 0) {
- logLastError("openssl.errorLoadingPrivateKey");
- return false;
- }
- if (SSL_CTX_check_private_key(state.sslCtx) <= 0) {
- logLastError("openssl.errorPrivateKeyCheck");
- return false;
- }
- // Try to read DH parameters from the (first) SSLCertificateFile
- if (index == SSL_AIDX_RSA) {
- BIO_reset(certificateBIO);
- if (!OPENSSL_3) {
- var dh = PEM_read_bio_DHparams(certificateBIO, MemorySegment.NULL, MemorySegment.NULL, MemorySegment.NULL);
- if (!MemorySegment.NULL.equals(dh)) {
- SSL_CTX_set_tmp_dh(state.sslCtx, dh);
- DH_free(dh);
- }
- } else {
- var pkey = PEM_read_bio_Parameters(certificateBIO, MemorySegment.NULL);
- if (!MemorySegment.NULL.equals(pkey)) {
- int numBits = EVP_PKEY_get_bits(pkey);
- if (SSL_CTX_set0_tmp_dh_pkey(state.sslCtx, pkey) <= 0) {
- EVP_PKEY_free(pkey);
- } else {
- log.debug(sm.getString("openssl.setCustomDHParameters", Integer.valueOf(numBits), certificate.getCertificateFile()));
- }
- } else {
- SSL_CTX_ctrl(state.sslCtx, SSL_CTRL_SET_DH_AUTO(), 1, MemorySegment.NULL);
- }
- }
- }
- // Similarly, try to read the ECDH curve name from SSLCertificateFile...
- BIO_reset(certificateBIO);
- if (!OPENSSL_3) {
- var ecparams = PEM_read_bio_ECPKParameters(certificateBIO, MemorySegment.NULL, MemorySegment.NULL, MemorySegment.NULL);
- if (!MemorySegment.NULL.equals(ecparams)) {
- int nid = EC_GROUP_get_curve_name(ecparams);
- var eckey = EC_KEY_new_by_curve_name(nid);
- SSL_CTX_set_tmp_ecdh(state.sslCtx, eckey);
- EC_KEY_free(eckey);
- EC_GROUP_free(ecparams);
- }
- // Set callback for DH parameters
- SSL_CTX_set_tmp_dh_callback(state.sslCtx, SSL_CTX_set_tmp_dh_callback$dh.allocate(new TmpDHCallback(), contextArena));
- } else {
- var ecparams = PEM_ASN1_read_bio(d2i_ECPKParameters$SYMBOL(),
- PEM_STRING_ECPARAMETERS(), certificateBIO, MemorySegment.NULL, MemorySegment.NULL, MemorySegment.NULL);
- if (!MemorySegment.NULL.equals(ecparams)) {
- int curveNid = EC_GROUP_get_curve_name(ecparams);
- var curveNidAddress = localArena.allocateFrom(ValueLayout.JAVA_INT, curveNid);
- if (SSL_CTX_set1_groups(state.sslCtx, curveNidAddress, 1) <= 0) {
- curveNid = 0;
- }
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("openssl.setECDHCurve", Integer.valueOf(curveNid),
- certificate.getCertificateFile()));
- }
- EC_GROUP_free(ecparams);
- }
- }
- // Set certificate chain file
- if (certificate.getCertificateChainFile() != null) {
- byte[] certificateChainBytes = null;
- try (Resource resource = ConfigFileLoader.getSource().getResource(certificate.getCertificateChainFile())) {
- certificateChainBytes = resource.getInputStream().readAllBytes();
- } catch (IOException e) {
- log.error(sm.getString("openssl.errorLoadingCertificate", certificate.getCertificateChainFile()), e);
- return false;
- }
- MemorySegment certificateChainBytesNative = localArena.allocateFrom(ValueLayout.JAVA_BYTE, certificateChainBytes);
- MemorySegment certificateChainBIO = BIO_new(BIO_s_mem());
- try {
- if (BIO_write(certificateChainBIO, certificateChainBytesNative, certificateChainBytes.length) <= 0) {
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificate.getCertificateChainFile(), getLastError()));
- return false;
- }
- MemorySegment certChainEntry =
- PEM_read_bio_X509_AUX(certificateChainBIO, MemorySegment.NULL, MemorySegment.NULL, MemorySegment.NULL);
- while (!MemorySegment.NULL.equals(certChainEntry)) {
- if (SSL_CTX_add0_chain_cert(state.sslCtx, certChainEntry) <= 0) {
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificate.getCertificateChainFile(), getLastError()));
- }
- certChainEntry =
- PEM_read_bio_X509_AUX(certificateChainBIO, MemorySegment.NULL, MemorySegment.NULL, MemorySegment.NULL);
- }
- // EOF is accepted, otherwise log an error
- if ((ERR_peek_last_error() & ERR_REASON_MASK()) == PEM_R_NO_START_LINE()) {
- ERR_clear_error();
- } else {
- log.error(sm.getString("openssl.errorLoadingCertificateWithError",
- certificate.getCertificateChainFile(), getLastError()));
- }
- } finally {
- BIO_free(certificateChainBIO);
- }
- }
- // Set revocation
- MemorySegment certificateStore = SSL_CTX_get_cert_store(state.sslCtx);
- if (sslHostConfig.getCertificateRevocationListFile() != null) {
- MemorySegment x509Lookup = X509_STORE_add_lookup(certificateStore, X509_LOOKUP_file());
- var certificateRevocationListFileNative =
- localArena.allocateFrom(SSLHostConfig.adjustRelativePath(sslHostConfig.getCertificateRevocationListFile()));
- if (X509_LOOKUP_load_file(x509Lookup, certificateRevocationListFileNative,
- X509_FILETYPE_PEM()) <= 0) {
- log.error(sm.getString("openssl.errorLoadingCertificateRevocationListWithError",
- sslHostConfig.getCertificateRevocationListFile(), getLastError()));
- }
- }
- if (sslHostConfig.getCertificateRevocationListPath() != null) {
- MemorySegment x509Lookup = X509_STORE_add_lookup(certificateStore, X509_LOOKUP_hash_dir());
- var certificateRevocationListPathNative =
- localArena.allocateFrom(SSLHostConfig.adjustRelativePath(sslHostConfig.getCertificateRevocationListPath()));
- if (X509_LOOKUP_add_dir(x509Lookup, certificateRevocationListPathNative,
- X509_FILETYPE_PEM()) <= 0) {
- log.error(sm.getString("openssl.errorLoadingCertificateRevocationListWithError",
- sslHostConfig.getCertificateRevocationListPath(), getLastError()));
- }
- }
- X509_STORE_set_flags(certificateStore, X509_V_FLAG_CRL_CHECK() | X509_V_FLAG_CRL_CHECK_ALL());
- } finally {
- BIO_free(certificateBIO);
- }
- } else {
- String alias = certificate.getCertificateKeyAlias();
- X509KeyManager x509KeyManager = certificate.getCertificateKeyManager();
- if (alias == null) {
- alias = "tomcat";
- }
- X509Certificate[] chain = x509KeyManager.getCertificateChain(alias);
- if (chain == null) {
- alias = findAlias(x509KeyManager, certificate);
- chain = x509KeyManager.getCertificateChain(alias);
- }
- StringBuilder sb = new StringBuilder(BEGIN_KEY);
- sb.append(Base64.getMimeEncoder(64, new byte[] {'\n'}).encodeToString(x509KeyManager.getPrivateKey(alias).getEncoded()));
- sb.append(END_KEY);
- var rawCertificate = localArena.allocateFrom(ValueLayout.JAVA_BYTE, chain[0].getEncoded());
- var rawCertificatePointer = localArena.allocateFrom(ValueLayout.ADDRESS, rawCertificate);
- var rawKey = localArena.allocateFrom(ValueLayout.JAVA_BYTE, sb.toString().getBytes(StandardCharsets.US_ASCII));
- var x509cert = d2i_X509(MemorySegment.NULL, rawCertificatePointer, rawCertificate.byteSize());
- if (MemorySegment.NULL.equals(x509cert)) {
- logLastError("openssl.errorLoadingCertificate");
- return false;
- }
- MemorySegment keyBIO = BIO_new(BIO_s_mem());
- try {
- BIO_write(keyBIO, rawKey, (int) rawKey.byteSize());
- MemorySegment privateKeyAddress = PEM_read_bio_PrivateKey(keyBIO, MemorySegment.NULL, MemorySegment.NULL, MemorySegment.NULL);
- if (MemorySegment.NULL.equals(privateKeyAddress)) {
- logLastError("openssl.errorLoadingPrivateKey");
- return false;
- }
- if (SSL_CTX_use_certificate(state.sslCtx, x509cert) <= 0) {
- logLastError("openssl.errorLoadingCertificate");
- return false;
- }
- if (SSL_CTX_use_PrivateKey(state.sslCtx, privateKeyAddress) <= 0) {
- logLastError("openssl.errorLoadingPrivateKey");
- return false;
- }
- if (SSL_CTX_check_private_key(state.sslCtx) <= 0) {
- logLastError("openssl.errorPrivateKeyCheck");
- return false;
- }
- if (!OPENSSL_3) {
- // Set callback for DH parameters
- SSL_CTX_set_tmp_dh_callback(state.sslCtx,
- SSL_CTX_set_tmp_dh_callback$dh.allocate(new TmpDHCallback(), contextArena));
- } else {
- BIO_reset(keyBIO);
- var pkey = PEM_read_bio_Parameters(keyBIO, MemorySegment.NULL);
- if (!MemorySegment.NULL.equals(pkey)) {
- int numBits = EVP_PKEY_get_bits(pkey);
- if (SSL_CTX_set0_tmp_dh_pkey(state.sslCtx, pkey) <= 0) {
- EVP_PKEY_free(pkey);
- } else {
- log.debug(sm.getString("openssl.setCustomDHParameters", Integer.valueOf(numBits),
- certificate.getCertificateFile()));
- }
- } else {
- SSL_CTX_ctrl(state.sslCtx, SSL_CTRL_SET_DH_AUTO(), 1, MemorySegment.NULL);
- }
- }
- for (int i = 1; i < chain.length; i++) {
- var rawCertificateChain = localArena.allocateFrom(ValueLayout.JAVA_BYTE, chain[i].getEncoded());
- var rawCertificateChainPointer = localArena.allocateFrom(ValueLayout.ADDRESS, rawCertificateChain);
- var x509certChain = d2i_X509(MemorySegment.NULL, rawCertificateChainPointer, rawCertificateChain.byteSize());
- if (MemorySegment.NULL.equals(x509certChain)) {
- logLastError("openssl.errorLoadingCertificate");
- return false;
- }
- if (SSL_CTX_add0_chain_cert(state.sslCtx, x509certChain) <= 0) {
- logLastError("openssl.errorAddingCertificate");
- return false;
- }
- }
- } finally {
- BIO_free(keyBIO);
- }
- }
- return true;
- }
-
-
- private static int getCertificateIndex(SSLHostConfigCertificate certificate) {
- int result = -1;
- // If the type is undefined there will only be one certificate (enforced
- // in SSLHostConfig) so use the RSA slot.
- if (certificate.getType() == Type.RSA || certificate.getType() == Type.UNDEFINED) {
- result = SSL_AIDX_RSA;
- } else if (certificate.getType() == Type.EC) {
- result = SSL_AIDX_ECC;
- } else if (certificate.getType() == Type.DSA) {
- result = SSL_AIDX_DSA;
- } else {
- result = SSL_AIDX_MAX;
- }
- return result;
- }
-
-
- /*
- * Find a valid alias when none was specified in the config.
- */
- private static String findAlias(X509KeyManager keyManager,
- SSLHostConfigCertificate certificate) {
-
- Type type = certificate.getType();
- String result = null;
-
- List<Type> candidateTypes = new ArrayList<>();
- if (Type.UNDEFINED.equals(type)) {
- // Try all types to find an suitable alias
- candidateTypes.addAll(Arrays.asList(Type.values()));
- candidateTypes.remove(Type.UNDEFINED);
- } else {
- // Look for the specific type to find a suitable alias
- candidateTypes.add(type);
- }
-
- Iterator<Type> iter = candidateTypes.iterator();
- while (result == null && iter.hasNext()) {
- result = keyManager.chooseServerAlias(iter.next().toString(), null, null);
- }
-
- return result;
- }
-
- private static X509TrustManager chooseTrustManager(TrustManager[] managers) {
- for (TrustManager m : managers) {
- if (m instanceof X509TrustManager) {
- return (X509TrustManager) m;
- }
- }
- throw new IllegalStateException(sm.getString("openssl.trustManagerMissing"));
- }
-
- private static X509Certificate[] certificates(byte[][] chain) {
- X509Certificate[] peerCerts = new X509Certificate[chain.length];
- for (int i = 0; i < peerCerts.length; i++) {
- peerCerts[i] = new OpenSSLX509Certificate(chain[i]);
- }
- return peerCerts;
- }
-
-
- private static void logLastError(String string) {
- String message = getLastError();
- if (message != null) {
- log.error(sm.getString(string, message));
- }
- }
-
-
- /**
- * Many calls to SSL methods do not check the last error. Those that do
- * check the last error need to ensure that any previously ignored error is
- * cleared prior to the method call else errors may be falsely reported.
- * Ideally, before any SSL_read, SSL_write, clearLastError should always
- * be called, and getLastError should be called after on any negative or
- * zero result.
- * @return the first error in the stack
- */
- static String getLastError() {
- String sslError = null;
- long error = ERR_get_error();
- if (error != SSL_ERROR_NONE()) {
- try (var localArena = Arena.ofConfined()) {
- do {
- // Loop until getLastErrorNumber() returns SSL_ERROR_NONE
- var buf = localArena.allocate(ValueLayout.JAVA_BYTE, OPENSSL_ERROR_MESSAGE_BUFFER_SIZE);
- ERR_error_string_n(error, buf, OPENSSL_ERROR_MESSAGE_BUFFER_SIZE);
- String err = buf.getString(0);
- if (sslError == null) {
- sslError = err;
- }
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("engine.openSSLError", Long.toString(error), err));
- }
- } while ((error = ERR_get_error()) != SSL_ERROR_NONE());
- }
- }
- return sslError;
- }
-
-
- @Override
- public SSLSessionContext getServerSessionContext() {
- return sessionContext;
- }
-
- @Override
- public SSLEngine createSSLEngine() {
- return new OpenSSLEngine(cleaner, state.sslCtx, defaultProtocol, false, sessionContext,
- alpn, initialized,
- sslHostConfig.getCertificateVerificationDepth(),
- sslHostConfig.getCertificateVerification() == CertificateVerification.OPTIONAL_NO_CA,
- noOcspCheck);
- }
-
- @Override
- public SSLServerSocketFactory getServerSocketFactory() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SSLParameters getSupportedSSLParameters() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public X509Certificate[] getCertificateChain(String alias) {
- X509Certificate[] chain = null;
- X509KeyManager x509KeyManager = certificate.getCertificateKeyManager();
- if (x509KeyManager != null) {
- if (alias == null) {
- alias = "tomcat";
- }
- chain = x509KeyManager.getCertificateChain(alias);
- if (chain == null) {
- alias = findAlias(x509KeyManager, certificate);
- chain = x509KeyManager.getCertificateChain(alias);
- }
- }
-
- return chain;
- }
-
- @Override
- public X509Certificate[] getAcceptedIssuers() {
- X509Certificate[] acceptedCerts = null;
- if (x509TrustManager != null) {
- acceptedCerts = x509TrustManager.getAcceptedIssuers();
- }
- return acceptedCerts;
- }
-
-
- private static class ContextState implements Runnable {
-
- private final Arena stateArena = Arena.ofShared();
- private final MemorySegment sslCtx;
- private final MemorySegment confCtx;
-
- private ContextState(MemorySegment sslCtx, MemorySegment confCtx) {
- // Use another arena to avoid keeping a reference through segments
- // This also allows making further accesses to the main pointers safer
- this.sslCtx = sslCtx.reinterpret(ValueLayout.ADDRESS.byteSize(), stateArena,
- (MemorySegment t) -> SSL_CTX_free(t));
- if (!MemorySegment.NULL.equals(confCtx)) {
- this.confCtx = confCtx.reinterpret(ValueLayout.ADDRESS.byteSize(), stateArena,
- (MemorySegment t) -> SSL_CONF_CTX_free(t));
- } else {
- this.confCtx = null;
- }
- }
-
- @Override
- public void run() {
- stateArena.close();
- }
- }
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java
deleted file mode 100644
index d80b48d2c4..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java
+++ /dev/null
@@ -1,1697 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.lang.foreign.Arena;
-import java.lang.foreign.MemorySegment;
-import java.lang.foreign.ValueLayout;
-import java.lang.ref.Cleaner;
-import java.lang.ref.Cleaner.Cleanable;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.ByteBuffer;
-import java.nio.ReadOnlyBufferException;
-import java.security.Principal;
-import java.security.cert.Certificate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLPeerUnverifiedException;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSessionBindingEvent;
-import javax.net.ssl.SSLSessionBindingListener;
-import javax.net.ssl.SSLSessionContext;
-
-import static org.apache.tomcat.util.openssl.openssl_h.*;
-import static org.apache.tomcat.util.openssl.openssl_h_Compatibility.*;
-import static org.apache.tomcat.util.openssl.openssl_h_Macros.*;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.buf.Asn1Parser;
-import org.apache.tomcat.util.net.Constants;
-import org.apache.tomcat.util.net.SSLUtil;
-import org.apache.tomcat.util.net.openssl.ciphers.OpenSSLCipherConfigurationParser;
-import org.apache.tomcat.util.openssl.SSL_CTX_set_verify$callback;
-import org.apache.tomcat.util.openssl.SSL_set_info_callback$cb;
-import org.apache.tomcat.util.openssl.SSL_set_verify$callback;
-import org.apache.tomcat.util.res.StringManager;
-
-/**
- * Implements a {@link SSLEngine} using
- * <a href="https://www.openssl.org/docs/crypto/BIO_s_bio.html#EXAMPLE">OpenSSL
- * BIO abstractions</a>.
- */
-public final class OpenSSLEngine extends SSLEngine implements SSLUtil.ProtocolInfo {
-
- private static final Log log = LogFactory.getLog(OpenSSLEngine.class);
- private static final StringManager sm = StringManager.getManager(OpenSSLEngine.class);
-
- private static final Certificate[] EMPTY_CERTIFICATES = new Certificate[0];
-
- public static final Set<String> AVAILABLE_CIPHER_SUITES;
-
- public static final Set<String> IMPLEMENTED_PROTOCOLS_SET;
-
- static {
- final Set<String> availableCipherSuites = new LinkedHashSet<>(128);
- availableCipherSuites.addAll(OpenSSLLibrary.findCiphers("ALL"));
- AVAILABLE_CIPHER_SUITES = Collections.unmodifiableSet(availableCipherSuites);
- HashSet<String> protocols = new HashSet<>();
- protocols.add(Constants.SSL_PROTO_SSLv2Hello);
- protocols.add(Constants.SSL_PROTO_SSLv2);
- protocols.add(Constants.SSL_PROTO_SSLv3);
- protocols.add(Constants.SSL_PROTO_TLSv1);
- protocols.add(Constants.SSL_PROTO_TLSv1_1);
- protocols.add(Constants.SSL_PROTO_TLSv1_2);
- protocols.add(Constants.SSL_PROTO_TLSv1_3);
- IMPLEMENTED_PROTOCOLS_SET = Collections.unmodifiableSet(protocols);
- }
-
- private static final int MAX_PLAINTEXT_LENGTH = 16 * 1024; // 2^14
- private static final int MAX_COMPRESSED_LENGTH = MAX_PLAINTEXT_LENGTH + 1024;
- private static final int MAX_CIPHERTEXT_LENGTH = MAX_COMPRESSED_LENGTH + 1024;
-
- // Header (5) + Data (2^14) + Compression (1024) + Encryption (1024) + MAC (20) + Padding (256)
- private static final int MAX_ENCRYPTED_PACKET_LENGTH = MAX_CIPHERTEXT_LENGTH + 5 + 20 + 256;
-
- private enum ClientAuthMode {
- NONE,
- OPTIONAL,
- REQUIRE,
- }
-
- private static final String INVALID_CIPHER = "SSL_NULL_WITH_NULL_NULL";
-
- private static final ConcurrentHashMap<Long, EngineState> states = new ConcurrentHashMap<>();
- private static EngineState getState(MemorySegment ssl) {
- return states.get(Long.valueOf(ssl.address()));
- }
-
- private final EngineState state;
- private final Arena engineArena;
- private final Cleanable cleanable;
- private MemorySegment bufSegment = null;
-
- private enum Accepted { NOT, IMPLICIT, EXPLICIT }
- private Accepted accepted = Accepted.NOT;
- private enum PHAState { NONE, START, COMPLETE }
- private boolean handshakeFinished;
- private int currentHandshake;
- private boolean receivedShutdown;
- private volatile boolean destroyed;
-
- // Use an invalid cipherSuite until the handshake is completed
- // See http://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLEngine.html#getSession()
- private volatile String version;
- private volatile String cipher;
- private volatile String applicationProtocol;
-
- private volatile Certificate[] peerCerts;
- private volatile ClientAuthMode clientAuth = ClientAuthMode.NONE;
-
- // SSL Engine status variables
- private boolean isInboundDone;
- private boolean isOutboundDone;
- private boolean engineClosed;
- private boolean sendHandshakeError = false;
-
- private final boolean clientMode;
- private final String fallbackApplicationProtocol;
- private final OpenSSLSessionContext sessionContext;
- private final boolean alpn;
- private final boolean initialized;
- private final boolean certificateVerificationOptionalNoCA;
-
- private String selectedProtocol = null;
-
- private final OpenSSLSession session;
-
- /**
- * Creates a new instance
- *
- * @param sslCtx an OpenSSL {@code SSL_CTX} object
- * @param fallbackApplicationProtocol the fallback application protocol
- * @param clientMode {@code true} if this is used for clients, {@code false}
- * otherwise
- * @param sessionContext the {@link OpenSSLSessionContext} this
- * {@link SSLEngine} belongs to.
- * @param alpn {@code true} if alpn should be used, {@code false}
- * otherwise
- * @param initialized {@code true} if this instance gets its protocol,
- * cipher and client verification from the {@code SSL_CTX} {@code sslCtx}
- * @param certificateVerificationDepth Certificate verification depth
- * @param certificateVerificationOptionalNoCA Skip CA verification in
- * optional mode
- */
- OpenSSLEngine(Cleaner cleaner, MemorySegment sslCtx, String fallbackApplicationProtocol,
- boolean clientMode, OpenSSLSessionContext sessionContext, boolean alpn,
- boolean initialized, int certificateVerificationDepth,
- boolean certificateVerificationOptionalNoCA, boolean noOcspCheck) {
- if (sslCtx == null) {
- throw new IllegalArgumentException(sm.getString("engine.noSSLContext"));
- }
- engineArena = Arena.ofAuto();
- bufSegment = engineArena.allocate(MAX_ENCRYPTED_PACKET_LENGTH);
- session = new OpenSSLSession();
- var ssl = SSL_new(sslCtx);
- // Set ssl_info_callback
- SSL_set_info_callback(ssl, SSL_set_info_callback$cb.allocate(new InfoCallback(), engineArena));
- if (clientMode) {
- SSL_set_connect_state(ssl);
- } else {
- SSL_set_accept_state(ssl);
- }
- SSL_set_verify_result(ssl, X509_V_OK());
- try (var localArena = Arena.ofConfined()) {
- var internalBIOPointer = localArena.allocate(ValueLayout.ADDRESS);
- var networkBIOPointer = localArena.allocate(ValueLayout.ADDRESS);
- BIO_new_bio_pair(internalBIOPointer, 0, networkBIOPointer, 0);
- var internalBIO = internalBIOPointer.get(ValueLayout.ADDRESS, 0);
- var networkBIO = networkBIOPointer.get(ValueLayout.ADDRESS, 0);
- SSL_set_bio(ssl, internalBIO, internalBIO);
- state = new EngineState(ssl, networkBIO, certificateVerificationDepth, noOcspCheck);
- }
- this.fallbackApplicationProtocol = fallbackApplicationProtocol;
- this.clientMode = clientMode;
- this.sessionContext = sessionContext;
- this.alpn = alpn;
- this.initialized = initialized;
- this.certificateVerificationOptionalNoCA = certificateVerificationOptionalNoCA;
- cleanable = cleaner.register(this, state);
- }
-
- @Override
- public String getNegotiatedProtocol() {
- return selectedProtocol;
- }
-
- /**
- * Destroys this engine.
- */
- public synchronized void shutdown() {
- if (!destroyed) {
- destroyed = true;
- cleanable.clean();
- // internal errors can cause shutdown without marking the engine closed
- isInboundDone = isOutboundDone = engineClosed = true;
- bufSegment = null;
- }
- }
-
- /**
- * Write plain text data to the OpenSSL internal BIO
- *
- * Calling this function with src.remaining == 0 is undefined.
- * @throws SSLException if the OpenSSL error check fails
- */
- private int writePlaintextData(final MemorySegment ssl, final ByteBuffer src) throws SSLException {
- clearLastError();
- final int pos = src.position();
- final int len = Math.min(src.remaining(), MAX_PLAINTEXT_LENGTH);
- MemorySegment srcSegment = src.isDirect() ? MemorySegment.ofBuffer(src) : bufSegment;
- if (!src.isDirect()) {
- MemorySegment.copy(src.array(), pos, bufSegment, ValueLayout.JAVA_BYTE, 0, len);
- }
- final int sslWrote = SSL_write(ssl, srcSegment, len);
- if (sslWrote > 0) {
- src.position(pos + sslWrote);
- return sslWrote;
- } else {
- checkLastError();
- }
- return 0;
- }
-
- /**
- * Write encrypted data to the OpenSSL network BIO.
- * @throws SSLException if the OpenSSL error check fails
- */
- private int writeEncryptedData(final MemorySegment networkBIO, final ByteBuffer src) throws SSLException {
- clearLastError();
- final int pos = src.position();
- final int len = src.remaining();
- MemorySegment srcSegment = src.isDirect() ? MemorySegment.ofBuffer(src) : bufSegment;
- if (!src.isDirect()) {
- MemorySegment.copy(src.array(), pos, bufSegment, ValueLayout.JAVA_BYTE, 0, len);
- }
- final int netWrote = BIO_write(networkBIO, srcSegment, len);
- if (netWrote > 0) {
- src.position(pos + netWrote);
- return netWrote;
- } else {
- checkLastError();
- }
- return 0;
- }
-
- /**
- * Read plain text data from the OpenSSL internal BIO
- * @throws SSLException if the OpenSSL error check fails
- */
- private int readPlaintextData(final MemorySegment ssl, final ByteBuffer dst) throws SSLException {
- clearLastError();
- final int pos = dst.position();
- final int len = Math.min(dst.remaining(), MAX_ENCRYPTED_PACKET_LENGTH);
- MemorySegment dstSegment = dst.isDirect() ? MemorySegment.ofBuffer(dst) : bufSegment;
- final int sslRead = SSL_read(ssl, dstSegment, len);
- if (sslRead > 0) {
- if (!dst.isDirect()) {
- MemorySegment.copy(dstSegment, ValueLayout.JAVA_BYTE, 0, dst.array(), pos, sslRead);
- }
- dst.position(pos + sslRead);
- return sslRead;
- } else {
- checkLastError();
- }
- return 0;
- }
-
- /**
- * Read encrypted data from the OpenSSL network BIO
- * @throws SSLException if the OpenSSL error check fails
- */
- private int readEncryptedData(final MemorySegment networkBIO, final ByteBuffer dst, final int pending) throws SSLException {
- clearLastError();
- final int pos = dst.position();
- MemorySegment dstSegment = dst.isDirect() ? MemorySegment.ofBuffer(dst) : bufSegment;
- final int bioRead = BIO_read(networkBIO, dstSegment, pending);
- if (bioRead > 0) {
- if (!dst.isDirect()) {
- MemorySegment.copy(dstSegment, ValueLayout.JAVA_BYTE, 0, dst.array(), pos, bioRead);
- }
- dst.position(pos + bioRead);
- return bioRead;
- } else {
- checkLastError();
- }
- return 0;
- }
-
- @Override
- public synchronized SSLEngineResult wrap(final ByteBuffer[] srcs, final int offset, final int length, final ByteBuffer dst) throws SSLException {
- // Check to make sure the engine has not been closed
- if (destroyed) {
- return new SSLEngineResult(SSLEngineResult.Status.CLOSED, SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING, 0, 0);
- }
-
- // Throw required runtime exceptions
- if (srcs == null || dst == null) {
- throw new IllegalArgumentException(sm.getString("engine.nullBuffer"));
- }
- if (offset >= srcs.length || offset + length > srcs.length) {
- throw new IndexOutOfBoundsException(sm.getString("engine.invalidBufferArray",
- Integer.toString(offset), Integer.toString(length),
- Integer.toString(srcs.length)));
- }
- if (dst.isReadOnly()) {
- throw new ReadOnlyBufferException();
- }
- // Prepare OpenSSL to work in server mode and receive handshake
- if (accepted == Accepted.NOT) {
- beginHandshakeImplicitly();
- }
-
- // In handshake or close_notify stages, check if call to wrap was made
- // without regard to the handshake status.
- SSLEngineResult.HandshakeStatus handshakeStatus = getHandshakeStatus();
-
- if ((!handshakeFinished || engineClosed) && handshakeStatus == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) {
- return new SSLEngineResult(getEngineStatus(), SSLEngineResult.HandshakeStatus.NEED_UNWRAP, 0, 0);
- }
-
- int bytesProduced = 0;
- int pendingNet;
-
- // Check for pending data in the network BIO
- pendingNet = (int) BIO_ctrl_pending(state.networkBIO);
- if (pendingNet > 0) {
- // Do we have enough room in destination to write encrypted data?
- int capacity = dst.remaining();
- if (capacity < pendingNet) {
- return new SSLEngineResult(SSLEngineResult.Status.BUFFER_OVERFLOW, handshakeStatus, 0, 0);
- }
-
- // Write the pending data from the network BIO into the dst buffer
- try {
- bytesProduced = readEncryptedData(state.networkBIO, dst, pendingNet);
- } catch (Exception e) {
- throw new SSLException(e);
- }
-
- // If isOutboundDone is set, then the data from the network BIO
- // was the close_notify message -- we are not required to wait
- // for the receipt the peer's close_notify message -- shutdown.
- if (isOutboundDone) {
- shutdown();
- }
-
- return new SSLEngineResult(getEngineStatus(), getHandshakeStatus(), 0, bytesProduced);
- }
-
- // There was no pending data in the network BIO -- encrypt any application data
- int bytesConsumed = 0;
- int endOffset = offset + length;
- for (int i = offset; i < endOffset; ++i) {
- final ByteBuffer src = srcs[i];
- if (src == null) {
- throw new IllegalArgumentException(sm.getString("engine.nullBufferInArray"));
- }
- while (src.hasRemaining()) {
-
- int bytesWritten = 0;
- // Write plain text application data to the SSL engine
- try {
- bytesWritten = writePlaintextData(state.ssl, src);
- bytesConsumed += bytesWritten;
- } catch (Exception e) {
- throw new SSLException(e);
- }
-
- if (bytesWritten == 0) {
- throw new IllegalStateException(sm.getString("engine.failedToWriteBytes"));
- }
-
- // Check to see if the engine wrote data into the network BIO
- pendingNet = (int) BIO_ctrl_pending(state.networkBIO);
- if (pendingNet > 0) {
- // Do we have enough room in dst to write encrypted data?
- int capacity = dst.remaining();
- if (capacity < pendingNet) {
- return new SSLEngineResult(
- SSLEngineResult.Status.BUFFER_OVERFLOW, getHandshakeStatus(), bytesConsumed, bytesProduced);
- }
-
- // Write the pending data from the network BIO into the dst buffer
- try {
- bytesProduced += readEncryptedData(state.networkBIO, dst, pendingNet);
- } catch (Exception e) {
- throw new SSLException(e);
- }
-
- return new SSLEngineResult(getEngineStatus(), getHandshakeStatus(), bytesConsumed, bytesProduced);
- }
- }
- }
-
- return new SSLEngineResult(getEngineStatus(), getHandshakeStatus(), bytesConsumed, bytesProduced);
- }
-
- @Override
- public synchronized SSLEngineResult unwrap(final ByteBuffer src, final ByteBuffer[] dsts, final int offset, final int length) throws SSLException {
- // Check to make sure the engine has not been closed
- if (destroyed) {
- return new SSLEngineResult(SSLEngineResult.Status.CLOSED, SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING, 0, 0);
- }
-
- // Throw required runtime exceptions
- if (src == null || dsts == null) {
- throw new IllegalArgumentException(sm.getString("engine.nullBuffer"));
- }
- if (offset >= dsts.length || offset + length > dsts.length) {
- throw new IndexOutOfBoundsException(sm.getString("engine.invalidBufferArray",
- Integer.toString(offset), Integer.toString(length),
- Integer.toString(dsts.length)));
- }
- int capacity = 0;
- final int endOffset = offset + length;
- for (int i = offset; i < endOffset; i++) {
- ByteBuffer dst = dsts[i];
- if (dst == null) {
- throw new IllegalArgumentException(sm.getString("engine.nullBufferInArray"));
- }
- if (dst.isReadOnly()) {
- throw new ReadOnlyBufferException();
- }
- capacity += dst.remaining();
- }
-
- // Prepare OpenSSL to work in server mode and receive handshake
- if (accepted == Accepted.NOT) {
- beginHandshakeImplicitly();
- }
-
- // In handshake or close_notify stages, check if call to unwrap was made
- // without regard to the handshake status.
- SSLEngineResult.HandshakeStatus handshakeStatus = getHandshakeStatus();
- if ((!handshakeFinished || engineClosed) && handshakeStatus == SSLEngineResult.HandshakeStatus.NEED_WRAP) {
- return new SSLEngineResult(getEngineStatus(), SSLEngineResult.HandshakeStatus.NEED_WRAP, 0, 0);
- }
-
- int len = src.remaining();
-
- // protect against protocol overflow attack vector
- if (len > MAX_ENCRYPTED_PACKET_LENGTH) {
- isInboundDone = true;
- isOutboundDone = true;
- engineClosed = true;
- shutdown();
- throw new SSLException(sm.getString("engine.oversizedPacket"));
- }
-
- // Write encrypted data to network BIO
- int written = 0;
- try {
- written = writeEncryptedData(state.networkBIO, src);
- } catch (Exception e) {
- throw new SSLException(e);
- }
-
- // There won't be any application data until we're done handshaking
- //
- // We first check handshakeFinished to eliminate the overhead of extra JNI call if possible.
- int pendingApp = pendingReadableBytesInSSL();
- if (!handshakeFinished) {
- pendingApp = 0;
- }
- int bytesProduced = 0;
- int idx = offset;
- // Do we have enough room in dsts to write decrypted data?
- if (capacity == 0) {
- return new SSLEngineResult(SSLEngineResult.Status.BUFFER_OVERFLOW, getHandshakeStatus(), written, 0);
- }
-
- while (pendingApp > 0) {
- if (idx == endOffset) {
- // Destination buffer state changed (no remaining space although
- // capacity is still available), so break loop with an error
- throw new IllegalStateException(sm.getString("engine.invalidDestinationBuffersState"));
- }
- // Write decrypted data to dsts buffers
- while (idx < endOffset) {
- ByteBuffer dst = dsts[idx];
- if (!dst.hasRemaining()) {
- idx++;
- continue;
- }
-
- if (pendingApp <= 0) {
- break;
- }
-
- int bytesRead;
- try {
- bytesRead = readPlaintextData(state.ssl, dst);
- } catch (Exception e) {
- throw new SSLException(e);
- }
-
- if (bytesRead == 0) {
- // This should not be possible. pendingApp is positive
- // therefore the read should have read at least one byte.
- throw new IllegalStateException(sm.getString("engine.failedToReadAvailableBytes"));
- }
-
- bytesProduced += bytesRead;
- pendingApp -= bytesRead;
- capacity -= bytesRead;
-
- if (!dst.hasRemaining()) {
- idx++;
- }
- }
- if (capacity == 0) {
- break;
- } else if (pendingApp == 0) {
- pendingApp = pendingReadableBytesInSSL();
- }
- }
-
- // Check to see if we received a close_notify message from the peer
- if (!receivedShutdown && (SSL_get_shutdown(state.ssl) & SSL_RECEIVED_SHUTDOWN()) == SSL_RECEIVED_SHUTDOWN()) {
- receivedShutdown = true;
- closeOutbound();
- closeInbound();
- }
-
- if (bytesProduced == 0 && (written == 0 || (written > 0 && !src.hasRemaining() && handshakeFinished))) {
- return new SSLEngineResult(SSLEngineResult.Status.BUFFER_UNDERFLOW, getHandshakeStatus(), written, 0);
- } else {
- return new SSLEngineResult(getEngineStatus(), getHandshakeStatus(), written, bytesProduced);
- }
- }
-
- private int pendingReadableBytesInSSL()
- throws SSLException {
- // NOTE: Calling a fake read is necessary before calling pendingReadableBytesInSSL because
- // SSL_pending will return 0 if OpenSSL has not started the current TLS record
- // See https://www.openssl.org/docs/manmaster/man3/SSL_pending.html
- clearLastError();
- int lastPrimingReadResult = SSL_read(state.ssl, MemorySegment.NULL, 0); // priming read
- // check if SSL_read returned <= 0. In this case we need to check the error and see if it was something
- // fatal.
- if (lastPrimingReadResult <= 0) {
- checkLastError();
- }
- int pendingReadableBytesInSSL = SSL_pending(state.ssl);
-
- // TLS 1.0 needs additional handling
- if (Constants.SSL_PROTO_TLSv1.equals(version) && lastPrimingReadResult == 0 &&
- pendingReadableBytesInSSL == 0) {
- // Perform another priming read
- lastPrimingReadResult = SSL_read(state.ssl, MemorySegment.NULL, 0);
- if (lastPrimingReadResult <= 0) {
- checkLastError();
- }
- pendingReadableBytesInSSL = SSL_pending(state.ssl);
- }
-
- return pendingReadableBytesInSSL;
- }
-
- @Override
- public Runnable getDelegatedTask() {
- // Currently, we do not delegate SSL computation tasks
- return null;
- }
-
- @Override
- public synchronized void closeInbound() throws SSLException {
- if (isInboundDone) {
- return;
- }
-
- isInboundDone = true;
- engineClosed = true;
-
- shutdown();
-
- if (accepted != Accepted.NOT && !receivedShutdown) {
- throw new SSLException(sm.getString("engine.inboundClose"));
- }
- }
-
- @Override
- public synchronized boolean isInboundDone() {
- return isInboundDone || engineClosed;
- }
-
- @Override
- public synchronized void closeOutbound() {
- if (isOutboundDone) {
- return;
- }
-
- isOutboundDone = true;
- engineClosed = true;
-
- if (accepted != Accepted.NOT && !destroyed) {
- int mode = SSL_get_shutdown(state.ssl);
- if ((mode & SSL_SENT_SHUTDOWN()) != SSL_SENT_SHUTDOWN()) {
- SSL_shutdown(state.ssl);
- }
- } else {
- // engine closing before initial handshake
- shutdown();
- }
- }
-
- @Override
- public synchronized boolean isOutboundDone() {
- return isOutboundDone;
- }
-
- @Override
- public String[] getSupportedCipherSuites() {
- Set<String> availableCipherSuites = AVAILABLE_CIPHER_SUITES;
- return availableCipherSuites.toArray(new String[0]);
- }
-
- @Override
- public synchronized String[] getEnabledCipherSuites() {
- if (destroyed) {
- return new String[0];
- }
- String[] enabled = OpenSSLLibrary.getCiphers(state.ssl);
- if (enabled == null) {
- return new String[0];
- } else {
- for (int i = 0; i < enabled.length; i++) {
- String mapped = OpenSSLCipherConfigurationParser.openSSLToJsse(enabled[i]);
- if (mapped != null) {
- enabled[i] = mapped;
- }
- }
- return enabled;
- }
- }
-
- @Override
- public synchronized void setEnabledCipherSuites(String[] cipherSuites) {
- if (initialized) {
- return;
- }
- if (cipherSuites == null) {
- throw new IllegalArgumentException(sm.getString("engine.nullCipherSuite"));
- }
- if (destroyed) {
- return;
- }
- final StringBuilder buf = new StringBuilder();
- for (String cipherSuite : cipherSuites) {
- if (cipherSuite == null) {
- break;
- }
- String converted = OpenSSLCipherConfigurationParser.jsseToOpenSSL(cipherSuite);
- if (!AVAILABLE_CIPHER_SUITES.contains(cipherSuite)) {
- log.debug(sm.getString("engine.unsupportedCipher", cipherSuite, converted));
- }
- if (converted != null) {
- cipherSuite = converted;
- }
-
- buf.append(cipherSuite);
- buf.append(':');
- }
-
- if (buf.length() == 0) {
- throw new IllegalArgumentException(sm.getString("engine.emptyCipherSuite"));
- }
- buf.setLength(buf.length() - 1);
-
- final String cipherSuiteSpec = buf.toString();
- try (var localArena = Arena.ofConfined()) {
- SSL_set_cipher_list(state.ssl, localArena.allocateFrom(cipherSuiteSpec));
- } catch (Exception e) {
- throw new IllegalStateException(sm.getString("engine.failedCipherSuite", cipherSuiteSpec), e);
- }
- }
-
- @Override
- public String[] getSupportedProtocols() {
- return IMPLEMENTED_PROTOCOLS_SET.toArray(new String[0]);
- }
-
- @Override
- public synchronized String[] getEnabledProtocols() {
- if (destroyed) {
- return new String[0];
- }
- List<String> enabled = new ArrayList<>();
- // Seems like there is no way to explicitly disable SSLv2Hello in OpenSSL so it is always enabled
- enabled.add(Constants.SSL_PROTO_SSLv2Hello);
- long opts = SSL_get_options(state.ssl);
- if ((opts & SSL_OP_NO_TLSv1()) == 0) {
- enabled.add(Constants.SSL_PROTO_TLSv1);
- }
- if ((opts & SSL_OP_NO_TLSv1_1()) == 0) {
- enabled.add(Constants.SSL_PROTO_TLSv1_1);
- }
- if ((opts & SSL_OP_NO_TLSv1_2()) == 0) {
- enabled.add(Constants.SSL_PROTO_TLSv1_2);
- }
- if ((opts & SSL_OP_NO_TLSv1_3()) == 0) {
- enabled.add(Constants.SSL_PROTO_TLSv1_3);
- }
- if ((opts & SSL_OP_NO_SSLv2()) == 0) {
- enabled.add(Constants.SSL_PROTO_SSLv2);
- }
- if ((opts & SSL_OP_NO_SSLv3()) == 0) {
- enabled.add(Constants.SSL_PROTO_SSLv3);
- }
- int size = enabled.size();
- if (size == 0) {
- return new String[0];
- } else {
- return enabled.toArray(new String[size]);
- }
- }
-
- @Override
- public synchronized void setEnabledProtocols(String[] protocols) {
- if (initialized) {
- return;
- }
- if (protocols == null) {
- // This is correct from the API docs
- throw new IllegalArgumentException();
- }
- if (destroyed) {
- return;
- }
- boolean sslv2 = false;
- boolean sslv3 = false;
- boolean tlsv1 = false;
- boolean tlsv1_1 = false;
- boolean tlsv1_2 = false;
- boolean tlsv1_3 = false;
- for (String p : protocols) {
- if (!IMPLEMENTED_PROTOCOLS_SET.contains(p)) {
- throw new IllegalArgumentException(sm.getString("engine.unsupportedProtocol", p));
- }
- if (p.equals(Constants.SSL_PROTO_SSLv2)) {
- sslv2 = true;
- } else if (p.equals(Constants.SSL_PROTO_SSLv3)) {
- sslv3 = true;
- } else if (p.equals(Constants.SSL_PROTO_TLSv1)) {
- tlsv1 = true;
- } else if (p.equals(Constants.SSL_PROTO_TLSv1_1)) {
- tlsv1_1 = true;
- } else if (p.equals(Constants.SSL_PROTO_TLSv1_2)) {
- tlsv1_2 = true;
- } else if (p.equals(Constants.SSL_PROTO_TLSv1_3)) {
- tlsv1_3 = true;
- }
- }
- // Enable all and then disable what we not want
- SSL_set_options(state.ssl, SSL_OP_ALL());
-
- if (!sslv2) {
- SSL_set_options(state.ssl, SSL_OP_NO_SSLv2());
- }
- if (!sslv3) {
- SSL_set_options(state.ssl, SSL_OP_NO_SSLv3());
- }
- if (!tlsv1) {
- SSL_set_options(state.ssl, SSL_OP_NO_TLSv1());
- }
- if (!tlsv1_1) {
- SSL_set_options(state.ssl, SSL_OP_NO_TLSv1_1());
- }
- if (!tlsv1_2) {
- SSL_set_options(state.ssl, SSL_OP_NO_TLSv1_2());
- }
- if (!tlsv1_3) {
- SSL_set_options(state.ssl, SSL_OP_NO_TLSv1_3());
- }
- }
-
- @Override
- public SSLSession getSession() {
- return session;
- }
-
- @Override
- public synchronized void beginHandshake() throws SSLException {
- if (engineClosed || destroyed) {
- throw new SSLException(sm.getString("engine.engineClosed"));
- }
- switch (accepted) {
- case NOT:
- handshake();
- accepted = Accepted.EXPLICIT;
- break;
- case IMPLICIT:
- // A user did not start handshake by calling this method by themselves,
- // but handshake has been started already by wrap() or unwrap() implicitly.
- // Because it's the user's first time to call this method, it is unfair to
- // raise an exception. From the user's standpoint, they never asked for
- // renegotiation.
-
- accepted = Accepted.EXPLICIT; // Next time this method is invoked by the user, we should raise an exception.
- break;
- case EXPLICIT:
- renegotiate();
- break;
- }
- }
-
- private byte[] getPeerCertificate() {
- try (var localArena = Arena.ofConfined()) {
- MemorySegment/*(X509*)*/ x509 = (OpenSSLContext.OPENSSL_3 ? SSL_get1_peer_certificate(state.ssl) : SSL_get_peer_certificate(state.ssl));
- MemorySegment bufPointer = localArena.allocateFrom(ValueLayout.ADDRESS, MemorySegment.NULL);
- int length = i2d_X509(x509, bufPointer);
- if (length <= 0) {
- return null;
- }
- MemorySegment buf = bufPointer.get(ValueLayout.ADDRESS, 0);
- byte[] certificate = buf.reinterpret(length, localArena, null).toArray(ValueLayout.JAVA_BYTE);
- X509_free(x509);
- OPENSSL_free(buf);
- return certificate;
- }
- }
-
- private byte[][] getPeerCertChain() {
- MemorySegment/*STACK_OF(X509)*/ sk = SSL_get_peer_cert_chain(state.ssl);
- int len = OPENSSL_sk_num(sk);
- if (len <= 0) {
- return null;
- }
- byte[][] certificateChain = new byte[len][];
- try (var localArena = Arena.ofConfined()) {
- for (int i = 0; i < len; i++) {
- MemorySegment/*(X509*)*/ x509 = OPENSSL_sk_value(sk, i);
- MemorySegment bufPointer = localArena.allocateFrom(ValueLayout.ADDRESS, MemorySegment.NULL);
- int length = i2d_X509(x509, bufPointer);
- if (length < 0) {
- certificateChain[i] = new byte[0];
- continue;
- }
- MemorySegment buf = bufPointer.get(ValueLayout.ADDRESS, 0);
- byte[] certificate = buf.reinterpret(length, localArena, null).toArray(ValueLayout.JAVA_BYTE);
- certificateChain[i] = certificate;
- OPENSSL_free(buf);
- }
- return certificateChain;
- }
- }
-
- private String getProtocolNegotiated() {
- try (var localArena = Arena.ofConfined()) {
- MemorySegment lenAddress = localArena.allocate(ValueLayout.JAVA_INT);
- MemorySegment protocolPointer = localArena.allocateFrom(ValueLayout.ADDRESS, MemorySegment.NULL);
- SSL_get0_alpn_selected(state.ssl, protocolPointer, lenAddress);
- if (MemorySegment.NULL.equals(protocolPointer)) {
- return null;
- }
- int length = lenAddress.get(ValueLayout.JAVA_INT, 0);
- if (length == 0) {
- return null;
- }
- MemorySegment protocolAddress = protocolPointer.get(ValueLayout.ADDRESS, 0);
- byte[] name = protocolAddress.reinterpret(length, localArena, null).toArray(ValueLayout.JAVA_BYTE);
- if (log.isTraceEnabled()) {
- log.trace("Protocol negotiated [" + new String(name) + "]");
- }
- return new String(name);
- }
- }
-
- private void beginHandshakeImplicitly() throws SSLException {
- handshake();
- accepted = Accepted.IMPLICIT;
- }
-
- private void handshake() throws SSLException {
- currentHandshake = state.handshakeCount;
- clearLastError();
- int code = SSL_do_handshake(state.ssl);
- if (code <= 0) {
- checkLastError();
- } else {
- if (alpn) {
- selectedProtocol = getProtocolNegotiated();
- }
- session.lastAccessedTime = System.currentTimeMillis();
- // if SSL_do_handshake returns > 0 it means the handshake was finished. This means we can update
- // handshakeFinished directly and so eliminate unnecessary calls to SSL.isInInit(...)
- handshakeFinished = true;
- }
- }
-
- private void renegotiate() throws SSLException {
- if (log.isTraceEnabled()) {
- log.trace("Start renegotiate");
- }
- clearLastError();
- int code;
- if (SSL_get_version(state.ssl).getString(0).equals(Constants.SSL_PROTO_TLSv1_3)) {
- state.phaState = PHAState.START;
- code = SSL_verify_client_post_handshake(state.ssl);
- } else {
- code = SSL_renegotiate(state.ssl);
- }
- if (code <= 0) {
- checkLastError();
- }
- handshakeFinished = false;
- peerCerts = null;
- currentHandshake = state.handshakeCount;
- int code2 = SSL_do_handshake(state.ssl);
- if (code2 <= 0) {
- checkLastError();
- }
- }
-
- private void checkLastError() throws SSLException {
- String sslError = OpenSSLContext.getLastError();
- if (sslError != null) {
- // Many errors can occur during handshake and need to be reported
- if (!handshakeFinished) {
- sendHandshakeError = true;
- } else {
- throw new SSLException(sslError);
- }
- }
- }
-
-
- /**
- * Clear out any errors, but log a warning.
- */
- private static void clearLastError() {
- OpenSSLContext.getLastError();
- }
-
- private SSLEngineResult.Status getEngineStatus() {
- return engineClosed ? SSLEngineResult.Status.CLOSED : SSLEngineResult.Status.OK;
- }
-
- @Override
- public synchronized SSLEngineResult.HandshakeStatus getHandshakeStatus() {
- if (accepted == Accepted.NOT || destroyed) {
- return SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING;
- }
-
- // Check if we are in the initial handshake phase
- if (!handshakeFinished) {
-
- // There is pending data in the network BIO -- call wrap
- if (sendHandshakeError || BIO_ctrl_pending(state.networkBIO) != 0) {
- if (sendHandshakeError) {
- // After a last wrap, consider it is going to be done
- sendHandshakeError = false;
- currentHandshake++;
- }
- return SSLEngineResult.HandshakeStatus.NEED_WRAP;
- }
-
- /*
- * Tomcat Native stores a count of the completed handshakes in the
- * SSL instance and increments it every time a handshake is
- * completed. Comparing the handshake count when the handshake
- * started to the current handshake count enables this code to
- * detect when the handshake has completed.
- *
- * Obtaining client certificates after the connection has been
- * established requires additional checks. We need to trigger
- * additional reads until the certificates have been read but we
- * don't know how many reads we will need as it depends on both
- * client and network behaviour.
- *
- * The additional reads are triggered by returning NEED_UNWRAP
- * rather than FINISHED. This allows the standard I/O code to be
- * used.
- *
- * For TLSv1.2 and below, the handshake completes before the
- * renegotiation. We therefore use SSL.renegotiatePending() to
- * check on the current status of the renegotiation and return
- * NEED_UNWRAP until it completes which means the client
- * certificates will have been read from the client.
- *
- * For TLSv1.3, Tomcat Native sets a flag when post handshake
- * authentication is started and updates it once the client
- * certificate has been received. We therefore use
- * SSL.getPostHandshakeAuthInProgress() to check the current status
- * and return NEED_UNWRAP until that methods indicates that PHA is
- * no longer in progress.
- */
-
- // No pending data to be sent to the peer
- // Check to see if we have finished handshaking
- if (state.handshakeCount != currentHandshake && SSL_renegotiate_pending(state.ssl) == 0 &&
- (state.phaState != PHAState.START)) {
- if (alpn) {
- selectedProtocol = getProtocolNegotiated();
- }
- session.lastAccessedTime = System.currentTimeMillis();
- version = SSL_get_version(state.ssl).getString(0);
- handshakeFinished = true;
- return SSLEngineResult.HandshakeStatus.FINISHED;
- }
-
- // No pending data
- // Still handshaking / renegotiation / post-handshake auth pending
- // Must be waiting on the peer to send more data
- return SSLEngineResult.HandshakeStatus.NEED_UNWRAP;
- }
-
- // Check if we are in the shutdown phase
- if (engineClosed) {
- // Waiting to send the close_notify message
- if (BIO_ctrl_pending(state.networkBIO) != 0) {
- return SSLEngineResult.HandshakeStatus.NEED_WRAP;
- }
-
- // Must be waiting to receive the close_notify message
- return SSLEngineResult.HandshakeStatus.NEED_UNWRAP;
- }
-
- return SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING;
- }
-
- @Override
- public void setUseClientMode(boolean clientMode) {
- if (clientMode != this.clientMode) {
- throw new UnsupportedOperationException();
- }
- }
-
- @Override
- public boolean getUseClientMode() {
- return clientMode;
- }
-
- @Override
- public void setNeedClientAuth(boolean b) {
- setClientAuth(b ? ClientAuthMode.REQUIRE : ClientAuthMode.NONE);
- }
-
- @Override
- public boolean getNeedClientAuth() {
- return clientAuth == ClientAuthMode.REQUIRE;
- }
-
- @Override
- public void setWantClientAuth(boolean b) {
- setClientAuth(b ? ClientAuthMode.OPTIONAL : ClientAuthMode.NONE);
- }
-
- @Override
- public boolean getWantClientAuth() {
- return clientAuth == ClientAuthMode.OPTIONAL;
- }
-
- private void setClientAuth(ClientAuthMode mode) {
- if (clientMode) {
- return;
- }
- synchronized (this) {
- if (clientAuth == mode) {
- return;
- }
- state.certificateVerifyMode = switch (mode) {
- case NONE -> SSL_VERIFY_NONE();
- case REQUIRE -> SSL_VERIFY_FAIL_IF_NO_PEER_CERT();
- case OPTIONAL -> certificateVerificationOptionalNoCA ? OpenSSLContext.OPTIONAL_NO_CA : SSL_VERIFY_PEER();
- };
- // Set int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) callback
- int value = switch (mode) {
- case NONE -> SSL_VERIFY_NONE();
- case REQUIRE -> SSL_VERIFY_PEER() | SSL_VERIFY_FAIL_IF_NO_PEER_CERT();
- case OPTIONAL -> SSL_VERIFY_PEER();
- };
- // Note: Since a callback is always set by the context, the callback here could in theory
- // be set to NULL (at the time of creation of the SSL, the SSL_CTX will have a non null callback)
- SSL_set_verify(state.ssl, value, SSL_set_verify$callback.allocate(new VerifyCallback(), engineArena));
- clientAuth = mode;
- }
- }
-
- private static class InfoCallback implements SSL_set_info_callback$cb.Function {
- @Override
- public void apply(MemorySegment ssl, int where, int ret) {
- EngineState state = getState(ssl);
- if (state == null) {
- log.warn(sm.getString("engine.noSSL", Long.valueOf(ssl.address())));
- return;
- }
- if (0 != (where & SSL_CB_HANDSHAKE_DONE())) {
- state.handshakeCount++;
- }
- }
- }
-
- static class VerifyCallback implements SSL_set_verify$callback.Function, SSL_CTX_set_verify$callback.Function {
- @Override
- public int apply(int preverify_ok, MemorySegment /*X509_STORE_CTX*/ x509ctx) {
- MemorySegment ssl = X509_STORE_CTX_get_ex_data(x509ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
- EngineState state = getState(ssl);
- if (state == null) {
- log.warn(sm.getString("engine.noSSL", Long.valueOf(ssl.address())));
- return 0;
- }
- if (log.isTraceEnabled()) {
- log.trace("Verification in engine with mode [" + state.certificateVerifyMode + "] for " + state.ssl);
- }
- int ok = preverify_ok;
- int errnum = X509_STORE_CTX_get_error(x509ctx);
- int errdepth = X509_STORE_CTX_get_error_depth(x509ctx);
- state.phaState = PHAState.COMPLETE;
- if (state.certificateVerifyMode == -1 /*SSL_CVERIFY_UNSET*/ || state.certificateVerifyMode == SSL_VERIFY_NONE()) {
- return 1;
- }
- /*SSL_VERIFY_ERROR_IS_OPTIONAL(errnum) -> ((errnum == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)
- || (errnum == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN)
- || (errnum == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY)
- || (errnum == X509_V_ERR_CERT_UNTRUSTED)
- || (errnum == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE))*/
- boolean verifyErrorIsOptional = (errnum == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT())
- || (errnum == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN())
- || (errnum == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY())
- || (errnum == X509_V_ERR_CERT_UNTRUSTED())
- || (errnum == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE());
- if (verifyErrorIsOptional && (state.certificateVerifyMode == OpenSSLContext.OPTIONAL_NO_CA)) {
- ok = 1;
- SSL_set_verify_result(state.ssl, X509_V_OK());
- }
- /*
- * Expired certificates vs. "expired" CRLs: by default, OpenSSL
- * turns X509_V_ERR_CRL_HAS_EXPIRED into a "certificate_expired(45)"
- * SSL alert, but that's not really the message we should convey to the
- * peer (at the very least, it's confusing, and in many cases, it's also
- * inaccurate, as the certificate itself may very well not have expired
- * yet). We set the X509_STORE_CTX error to something which OpenSSL's
- * s3_both.c:ssl_verify_alarm_type() maps to SSL_AD_CERTIFICATE_UNKNOWN,
- * i.e. the peer will receive a "certificate_unknown(46)" alert.
- * We do not touch errnum, though, so that later on we will still log
- * the "real" error, as returned by OpenSSL.
- */
- if (ok == 0 && errnum == X509_V_ERR_CRL_HAS_EXPIRED()) {
- X509_STORE_CTX_set_error(x509ctx, -1);
- }
-
- // OCSP
- if (!state.noOcspCheck && (ok > 0)) {
- /* If there was an optional verification error, it's not
- * possible to perform OCSP validation since the issuer may be
- * missing/untrusted. Fail in that case.
- */
- if (verifyErrorIsOptional) {
- if (state.certificateVerifyMode != OpenSSLContext.OPTIONAL_NO_CA) {
- X509_STORE_CTX_set_error(x509ctx, X509_V_ERR_APPLICATION_VERIFICATION());
- errnum = X509_V_ERR_APPLICATION_VERIFICATION();
- ok = 0;
- }
- } else {
- int ocspResponse = processOCSP(x509ctx);
- if (ocspResponse == V_OCSP_CERTSTATUS_REVOKED()) {
- ok = 0;
- errnum = X509_STORE_CTX_get_error(x509ctx);
- } else if (ocspResponse == V_OCSP_CERTSTATUS_UNKNOWN()) {
- errnum = X509_STORE_CTX_get_error(x509ctx);
- if (errnum <= 0) {
- ok = 0;
- }
- }
- }
- }
-
- if (errdepth > state.certificateVerificationDepth) {
- // Certificate Verification: Certificate Chain too long
- ok = 0;
- }
- return ok;
- }
- }
-
- private static int processOCSP(MemorySegment /*X509_STORE_CTX*/ x509ctx) {
- int ocspResponse = V_OCSP_CERTSTATUS_UNKNOWN();
- MemorySegment x509 = X509_STORE_CTX_get_current_cert(x509ctx);
- if (!MemorySegment.NULL.equals(x509)) {
- // No need to check cert->valid, because ssl_verify_OCSP() only
- // is called if OpenSSL already successfully verified the certificate
- // (parameter "ok" in SSL_callback_SSL_verify() must be true).
- if (X509_check_issued(x509, x509) == X509_V_OK()) {
- // don't do OCSP checking for valid self-issued certs
- X509_STORE_CTX_set_error(x509ctx, X509_V_OK());
- } else {
- // If we can't get the issuer, we cannot perform OCSP verification
- MemorySegment issuer = X509_STORE_CTX_get0_current_issuer(x509ctx);
- if (!MemorySegment.NULL.equals(issuer)) {
- // sslutils.c ssl_ocsp_request(x509, issuer, x509ctx);
- int nid = X509_get_ext_by_NID(x509, NID_info_access(), -1);
- if (nid >= 0) {
- try (var localArenal = Arena.ofConfined()) {
- MemorySegment ext = X509_get_ext(x509, nid);
- MemorySegment os = X509_EXTENSION_get_data(ext);
- int length = ASN1_STRING_length(os);
- MemorySegment data = ASN1_STRING_get0_data(os);
- // ocsp_urls = decode_OCSP_url(os);
- byte[] asn1String = data.reinterpret(length, localArenal, null).toArray(ValueLayout.JAVA_BYTE);
- Asn1Parser parser = new Asn1Parser(asn1String);
- // Parse the byte sequence
- ArrayList<String> urls = new ArrayList<>();
- try {
- parseOCSPURLs(parser, urls);
- } catch (Exception e) {
- log.error(sm.getString("engine.ocspParseError"), e);
- }
- if (!urls.isEmpty()) {
- // Use OpenSSL to build OCSP request
- for (String urlString : urls) {
- try {
- URL url = (new URI(urlString)).toURL();
- ocspResponse = processOCSPRequest(url, issuer, x509, x509ctx, localArenal);
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("engine.ocspResponse", urlString,
- Integer.toString(ocspResponse)));
- }
- } catch (MalformedURLException | URISyntaxException e) {
- log.warn(sm.getString("engine.invalidOCSPURL", urlString));
- }
- if (ocspResponse != V_OCSP_CERTSTATUS_UNKNOWN()) {
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- return ocspResponse;
- }
-
- private static final int ASN1_SEQUENCE = 0x30;
- private static final int ASN1_OID = 0x06;
- private static final int ASN1_STRING = 0x86;
- private static final byte[] OCSP_OID = {0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01};
-
- private static void parseOCSPURLs(Asn1Parser parser, ArrayList<String> urls) {
- while (!parser.eof()) {
- int tag = parser.peekTag();
- if (tag == ASN1_SEQUENCE) {
- parser.parseTag(ASN1_SEQUENCE);
- parser.parseFullLength();
- } else if (tag == ASN1_OID) {
- parser.parseTag(ASN1_OID);
- int oidLen = parser.parseLength();
- byte[] oid = new byte[oidLen];
- parser.parseBytes(oid);
- if (Arrays.compareUnsigned(oid, 0, OCSP_OID.length, OCSP_OID, 0, OCSP_OID.length) == 0) {
- parser.parseTag(ASN1_STRING);
- int urlLen = parser.parseLength();
- byte[] url = new byte[urlLen];
- parser.parseBytes(url);
- urls.add(new String(url));
- }
- } else {
- return;
- }
- }
- }
-
- private static int processOCSPRequest(URL url, MemorySegment issuer, MemorySegment x509,
- MemorySegment /*X509_STORE_CTX*/ x509ctx, Arena localArena) {
- MemorySegment ocspRequest = MemorySegment.NULL;
- MemorySegment ocspResponse = MemorySegment.NULL;
- MemorySegment id = MemorySegment.NULL;
- MemorySegment ocspOneReq = MemorySegment.NULL;
- HttpURLConnection connection = null;
- MemorySegment basicResponse = MemorySegment.NULL;
- MemorySegment certId = MemorySegment.NULL;
- try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
- ocspRequest = OCSP_REQUEST_new();
- if (MemorySegment.NULL.equals(ocspRequest)) {
- return V_OCSP_CERTSTATUS_UNKNOWN();
- }
- id = OCSP_cert_to_id(MemorySegment.NULL, x509, issuer);
- if (MemorySegment.NULL.equals(id)) {
- return V_OCSP_CERTSTATUS_UNKNOWN();
- }
- ocspOneReq = OCSP_request_add0_id(ocspRequest, id);
- if (MemorySegment.NULL.equals(ocspOneReq)) {
- return V_OCSP_CERTSTATUS_UNKNOWN();
- }
- MemorySegment bufPointer = localArena.allocateFrom(ValueLayout.ADDRESS, MemorySegment.NULL);
- int requestLength = i2d_OCSP_REQUEST(ocspRequest, bufPointer);
- if (requestLength <= 0) {
- return V_OCSP_CERTSTATUS_UNKNOWN();
- }
- MemorySegment buf = bufPointer.get(ValueLayout.ADDRESS, 0);
- // HTTP request with the following header:
- // POST urlPath HTTP/1.1
- // Host: urlHost:urlPort
- // Content-Type: application/ocsp-request
- // Content-Length: ocspRequestData.length
- byte[] ocspRequestData = buf.reinterpret(requestLength, localArena, null).toArray(ValueLayout.JAVA_BYTE);
- connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("POST");
- connection.setDoInput(true);
- connection.setDoOutput(true);
- connection.setFixedLengthStreamingMode(requestLength);
- connection.setRequestProperty("Content-Type", "application/ocsp-request");
- connection.connect();
- connection.getOutputStream().write(ocspRequestData);
- int responseCode = connection.getResponseCode();
- if (responseCode != HttpURLConnection.HTTP_OK) {
- return V_OCSP_CERTSTATUS_UNKNOWN();
- }
- InputStream is = connection.getInputStream();
- int read = 0;
- byte[] responseBuf = new byte[1024];
- while ((read = is.read(responseBuf)) > 0) {
- baos.write(responseBuf, 0, read);
- }
- byte[] responseData = baos.toByteArray();
- var nativeResponseData = localArena.allocateFrom(ValueLayout.JAVA_BYTE, responseData);
- var nativeResponseDataPointer = localArena.allocateFrom(ValueLayout.ADDRESS, nativeResponseData);
- ocspResponse = d2i_OCSP_RESPONSE(MemorySegment.NULL, nativeResponseDataPointer, responseData.length);
- if (!MemorySegment.NULL.equals(ocspResponse)) {
- if (OCSP_response_status(ocspResponse) == OCSP_RESPONSE_STATUS_SUCCESSFUL()) {
- basicResponse = OCSP_response_get1_basic(ocspResponse);
- certId = OCSP_cert_to_id(MemorySegment.NULL, x509, issuer);
- if (MemorySegment.NULL.equals(certId)) {
- return V_OCSP_CERTSTATUS_UNKNOWN();
- }
- // Find by serial number and get the matching response
- MemorySegment singleResponse = OCSP_resp_get0(basicResponse, OCSP_resp_find(basicResponse, certId, -1));
- return OCSP_single_get0_status(singleResponse, MemorySegment.NULL,
- MemorySegment.NULL, MemorySegment.NULL, MemorySegment.NULL);
- }
- }
- } catch (Exception e) {
- log.warn(sm.getString("engine.ocspRequestError", url.toString()), e);
- } finally {
- if (MemorySegment.NULL.equals(ocspResponse)) {
- // Failed to get a valid response
- X509_STORE_CTX_set_error(x509ctx, X509_V_ERR_APPLICATION_VERIFICATION());
- }
- OCSP_CERTID_free(certId);
- OCSP_BASICRESP_free(basicResponse);
- OCSP_RESPONSE_free(ocspResponse);
- OCSP_REQUEST_free(ocspRequest);
- if (connection != null) {
- connection.disconnect();
- }
- }
- return V_OCSP_CERTSTATUS_UNKNOWN();
- }
-
- @Override
- public void setEnableSessionCreation(boolean b) {
- if (!b) {
- String msg = sm.getString("engine.noRestrictSessionCreation");
- throw new UnsupportedOperationException(msg);
- }
- }
-
- @Override
- public boolean getEnableSessionCreation() {
- return true;
- }
-
-
- private class OpenSSLSession implements SSLSession {
-
- // lazy init for memory reasons
- private Map<String, Object> values;
-
- // Last accessed time
- private long lastAccessedTime = -1;
-
- @Override
- public byte[] getId() {
- byte[] id = null;
- synchronized (OpenSSLEngine.this) {
- if (!destroyed) {
- try (var localArena = Arena.ofConfined()) {
- MemorySegment lenPointer = localArena.allocate(ValueLayout.JAVA_INT);
- var session = SSL_get_session(state.ssl);
- if (MemorySegment.NULL.equals(session)) {
- return new byte[0];
- }
- MemorySegment sessionId = SSL_SESSION_get_id(session, lenPointer);
- int len = lenPointer.get(ValueLayout.JAVA_INT, 0);
- id = (len == 0) ? new byte[0]
- : sessionId.reinterpret(len, localArena, null).toArray(ValueLayout.JAVA_BYTE);
- }
- }
- }
-
- return id;
- }
-
- @Override
- public SSLSessionContext getSessionContext() {
- return sessionContext;
- }
-
- @Override
- public long getCreationTime() {
- // We need to multiply by 1000 as OpenSSL uses seconds and we need milliseconds.
- long creationTime = 0;
- synchronized (OpenSSLEngine.this) {
- if (!destroyed) {
- var session = SSL_get_session(state.ssl);
- if (!MemorySegment.NULL.equals(session)) {
- creationTime = SSL_SESSION_get_time(session);
- }
- }
- }
- return creationTime * 1000L;
- }
-
- @Override
- public long getLastAccessedTime() {
- return (lastAccessedTime > 0) ? lastAccessedTime : getCreationTime();
- }
-
- @Override
- public void invalidate() {
- // NOOP
- }
-
- @Override
- public boolean isValid() {
- return false;
- }
-
- @Override
- public void putValue(String name, Object value) {
- if (name == null) {
- throw new IllegalArgumentException(sm.getString("engine.nullName"));
- }
- if (value == null) {
- throw new IllegalArgumentException(sm.getString("engine.nullValue"));
- }
- Map<String, Object> values = this.values;
- if (values == null) {
- // Use size of 2 to keep the memory overhead small
- values = this.values = new HashMap<>(2);
- }
- Object old = values.put(name, value);
- if (value instanceof SSLSessionBindingListener) {
- ((SSLSessionBindingListener) value).valueBound(new SSLSessionBindingEvent(this, name));
- }
- notifyUnbound(old, name);
- }
-
- @Override
- public Object getValue(String name) {
- if (name == null) {
- throw new IllegalArgumentException(sm.getString("engine.nullName"));
- }
- if (values == null) {
- return null;
- }
- return values.get(name);
- }
-
- @Override
- public void removeValue(String name) {
- if (name == null) {
- throw new IllegalArgumentException(sm.getString("engine.nullName"));
- }
- Map<String, Object> values = this.values;
- if (values == null) {
- return;
- }
- Object old = values.remove(name);
- notifyUnbound(old, name);
- }
-
- @Override
- public String[] getValueNames() {
- Map<String, Object> values = this.values;
- if (values == null || values.isEmpty()) {
- return new String[0];
- }
- return values.keySet().toArray(new String[0]);
- }
-
- private void notifyUnbound(Object value, String name) {
- if (value instanceof SSLSessionBindingListener) {
- ((SSLSessionBindingListener) value).valueUnbound(new SSLSessionBindingEvent(this, name));
- }
- }
-
- @Override
- public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException {
- // these are lazy created to reduce memory overhead
- Certificate[] c = peerCerts;
- if (c == null) {
- byte[] clientCert;
- byte[][] chain;
- synchronized (OpenSSLEngine.this) {
- if (destroyed || SSL_in_init(state.ssl) != 0) {
- throw new SSLPeerUnverifiedException(sm.getString("engine.unverifiedPeer"));
- }
- chain = getPeerCertChain();
- if (!clientMode) {
- // if used on the server side SSL_get_peer_cert_chain(...) will not include the remote peer certificate.
- // We use SSL_get_peer_certificate to get it in this case and add it to our array later.
- // See https://www.openssl.org/docs/ssl/SSL_get_peer_cert_chain.html
- clientCert = getPeerCertificate();
- } else {
- clientCert = null;
- }
- }
- if (chain == null && clientCert == null) {
- return null;
- }
- int len = 0;
- if (chain != null) {
- len += chain.length;
- }
-
- int i = 0;
- Certificate[] certificates;
- if (clientCert != null) {
- len++;
- certificates = new Certificate[len];
- certificates[i++] = new OpenSSLX509Certificate(clientCert);
- } else {
- certificates = new Certificate[len];
- }
- if (chain != null) {
- int a = 0;
- for (; i < certificates.length; i++) {
- certificates[i] = new OpenSSLX509Certificate(chain[a++]);
- }
- }
- c = peerCerts = certificates;
- }
- return c;
- }
-
- @Override
- public Certificate[] getLocalCertificates() {
- // FIXME (if possible): Not available in the OpenSSL API
- return EMPTY_CERTIFICATES;
- }
-
- @Override
- public Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
- Certificate[] peer = getPeerCertificates();
- if (peer == null || peer.length == 0) {
- return null;
- }
- return principal(peer);
- }
-
- @Override
- public Principal getLocalPrincipal() {
- Certificate[] local = getLocalCertificates();
- if (local == null || local.length == 0) {
- return null;
- }
- return principal(local);
- }
-
- private Principal principal(Certificate[] certs) {
- return ((java.security.cert.X509Certificate) certs[0]).getIssuerX500Principal();
- }
-
- @Override
- public String getCipherSuite() {
- if (cipher == null) {
- String ciphers;
- synchronized (OpenSSLEngine.this) {
- if (!handshakeFinished) {
- return INVALID_CIPHER;
- }
- if (destroyed) {
- return INVALID_CIPHER;
- }
- ciphers = SSL_CIPHER_get_name(SSL_get_current_cipher(state.ssl)).getString(0);
- }
- String c = OpenSSLCipherConfigurationParser.openSSLToJsse(ciphers);
- if (c != null) {
- cipher = c;
- }
- }
- return cipher;
- }
-
- @Override
- public String getProtocol() {
- String applicationProtocol = OpenSSLEngine.this.applicationProtocol;
- if (applicationProtocol == null) {
- applicationProtocol = fallbackApplicationProtocol;
- if (applicationProtocol != null) {
- OpenSSLEngine.this.applicationProtocol = applicationProtocol.replace(':', '_');
- } else {
- OpenSSLEngine.this.applicationProtocol = applicationProtocol = "";
- }
- }
- String version = null;
- synchronized (OpenSSLEngine.this) {
- if (!destroyed) {
- version = SSL_get_version(state.ssl).getString(0);
- }
- }
- if (applicationProtocol.isEmpty()) {
- return version;
- } else {
- return version + ':' + applicationProtocol;
- }
- }
-
- @Override
- public String getPeerHost() {
- // Not available for now in Tomcat (needs to be passed during engine creation)
- return null;
- }
-
- @Override
- public int getPeerPort() {
- // Not available for now in Tomcat (needs to be passed during engine creation)
- return 0;
- }
-
- @Override
- public int getPacketBufferSize() {
- return MAX_ENCRYPTED_PACKET_LENGTH;
- }
-
- @Override
- public int getApplicationBufferSize() {
- return MAX_PLAINTEXT_LENGTH;
- }
-
- }
-
- private static class EngineState implements Runnable {
-
- private final Arena stateArena = Arena.ofShared();
- private final MemorySegment ssl;
- private final MemorySegment networkBIO;
- private final int certificateVerificationDepth;
- private final boolean noOcspCheck;
-
- private PHAState phaState = PHAState.NONE;
- private int certificateVerifyMode = 0;
- private int handshakeCount = 0;
-
- private EngineState(MemorySegment ssl, MemorySegment networkBIO,
- int certificateVerificationDepth, boolean noOcspCheck) {
- states.put(Long.valueOf(ssl.address()), this);
- this.certificateVerificationDepth = certificateVerificationDepth;
- this.noOcspCheck = noOcspCheck;
- // Use another arena to avoid keeping a reference through segments
- // This also allows making further accesses to the main pointers safer
- this.ssl = ssl.reinterpret(ValueLayout.ADDRESS.byteSize(), stateArena,
- (MemorySegment t) -> SSL_free(t));
- this.networkBIO = networkBIO.reinterpret(ValueLayout.ADDRESS.byteSize(), stateArena,
- (MemorySegment t) -> BIO_free(t));
- }
-
- @Override
- public void run() {
- states.remove(Long.valueOf(ssl.address()));
- stateArena.close();
- }
- }
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLImplementation.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLImplementation.java
deleted file mode 100644
index 28d7ae2b8f..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLImplementation.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.net.ssl.SSLSession;
-
-import org.apache.tomcat.util.net.SSLHostConfigCertificate;
-import org.apache.tomcat.util.net.SSLImplementation;
-import org.apache.tomcat.util.net.SSLSupport;
-import org.apache.tomcat.util.net.SSLUtil;
-import org.apache.tomcat.util.net.jsse.JSSESupport;
-
-public class OpenSSLImplementation extends SSLImplementation {
-
- @Deprecated
- public SSLSupport getSSLSupport(SSLSession session) {
- return new JSSESupport(session, null);
- }
-
- @Override
- public SSLSupport getSSLSupport(SSLSession session, Map<String, List<String>> additionalAttributes) {
- return new JSSESupport(session, additionalAttributes);
- }
-
- @Override
- public SSLUtil getSSLUtil(SSLHostConfigCertificate certificate) {
- return new OpenSSLUtil(certificate);
- }
-
- public boolean isAlpnSupported() {
- // OpenSSL supported ALPN
- return true;
- }
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
deleted file mode 100644
index f6207d10e0..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-
-import java.lang.foreign.Arena;
-import java.lang.foreign.MemorySegment;
-import java.lang.foreign.ValueLayout;
-import java.security.SecureRandom;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.apache.tomcat.util.openssl.openssl_h.*;
-import static org.apache.tomcat.util.openssl.openssl_h_Compatibility.*;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.net.openssl.ciphers.OpenSSLCipherConfigurationParser;
-import org.apache.tomcat.util.res.StringManager;
-
-
-
-/**
- * Implementation of a global initialization of OpenSSL according to specified
- * configuration parameters.
- * Using this from a listener is completely optional, but is needed for
- * configuration and full cleanup of a few native memory allocations.
- */
-public class OpenSSLLibrary {
-
- private static final Log log = LogFactory.getLog(OpenSSLLibrary.class);
-
- /**
- * The string manager for this package.
- */
- protected static final StringManager sm = StringManager.getManager(OpenSSLLibrary.class);
-
-
- // ---------------------------------------------- Properties
- protected static String SSLEngine = "on"; //default on
- protected static String FIPSMode = "off"; // default off, valid only when SSLEngine="on"
- protected static String SSLRandomSeed = "builtin";
- protected static boolean fipsModeActive = false;
-
- /**
- * The "FIPS mode" level that we use as the argument to OpenSSL method
- * <code>FIPS_mode_set()</code> to enable FIPS mode and that we expect as
- * the return value of <code>FIPS_mode()</code> when FIPS mode is enabled.
- * <p>
- * In the future the OpenSSL library might grow support for different
- * non-zero "FIPS" modes that specify different allowed subsets of ciphers
- * or whatever, but nowadays only "1" is the supported value.
- * </p>
- * @see <a href="http://wiki.openssl.org/index.php/FIPS_mode_set%28%29">OpenSSL method FIPS_mode_set()</a>
- * @see <a href="http://wiki.openssl.org/index.php/FIPS_mode%28%29">OpenSSL method FIPS_mode()</a>
- */
- private static final int FIPS_ON = 1;
-
- private static final int FIPS_OFF = 0;
-
- protected static final Object lock = new Object();
-
- static MemorySegment enginePointer = MemorySegment.NULL;
-
- static void initLibrary() {
- synchronized (lock) {
- if (OpenSSLStatus.isLibraryInitialized()) {
- return;
- }
- long initParam = (OpenSSL_version_num() >= 0x3000000fL) ? 0 : OPENSSL_INIT_ENGINE_ALL_BUILTIN();
- OPENSSL_init_ssl(initParam, MemorySegment.NULL);
- OpenSSLStatus.setLibraryInitialized(true);
- }
- }
-
- /*
- { BN_get_rfc3526_prime_8192, NULL, 6145 },
- { BN_get_rfc3526_prime_6144, NULL, 4097 },
- { BN_get_rfc3526_prime_4096, NULL, 3073 },
- { BN_get_rfc3526_prime_3072, NULL, 2049 },
- { BN_get_rfc3526_prime_2048, NULL, 1025 },
- { BN_get_rfc2409_prime_1024, NULL, 0 }
- */
- static final class DHParam {
- final MemorySegment dh;
- final int min;
- private DHParam(MemorySegment dh, int min) {
- this.dh = dh;
- this.min = min;
- }
- }
- static final DHParam[] dhParameters = new DHParam[6];
-
- private static void initDHParameters() {
- var dh = DH_new();
- var p = BN_get_rfc3526_prime_8192(MemorySegment.NULL);
- var g = BN_new();
- BN_set_word(g, 2);
- DH_set0_pqg(dh, p, MemorySegment.NULL, g);
- dhParameters[0] = new DHParam(dh, 6145);
- dh = DH_new();
- p = BN_get_rfc3526_prime_6144(MemorySegment.NULL);
- g = BN_new();
- BN_set_word(g, 2);
- DH_set0_pqg(dh, p, MemorySegment.NULL, g);
- dhParameters[1] = new DHParam(dh, 4097);
- dh = DH_new();
- p = BN_get_rfc3526_prime_4096(MemorySegment.NULL);
- g = BN_new();
- BN_set_word(g, 2);
- DH_set0_pqg(dh, p, MemorySegment.NULL, g);
- dhParameters[2] = new DHParam(dh, 3073);
- dh = DH_new();
- p = BN_get_rfc3526_prime_3072(MemorySegment.NULL);
- g = BN_new();
- BN_set_word(g, 2);
- DH_set0_pqg(dh, p, MemorySegment.NULL, g);
- dhParameters[3] = new DHParam(dh, 2049);
- dh = DH_new();
- p = BN_get_rfc3526_prime_2048(MemorySegment.NULL);
- g = BN_new();
- BN_set_word(g, 2);
- DH_set0_pqg(dh, p, MemorySegment.NULL, g);
- dhParameters[4] = new DHParam(dh, 1025);
- dh = DH_new();
- p = BN_get_rfc2409_prime_1024(MemorySegment.NULL);
- g = BN_new();
- BN_set_word(g, 2);
- DH_set0_pqg(dh, p, MemorySegment.NULL, g);
- dhParameters[5] = new DHParam(dh, 0);
- }
-
- private static void freeDHParameters() {
- for (int i = 0; i < dhParameters.length; i++) {
- if (dhParameters[i] != null) {
- MemorySegment dh = dhParameters[i].dh;
- if (dh != null && !MemorySegment.NULL.equals(dh)) {
- DH_free(dh);
- dhParameters[i] = null;
- }
- }
- }
- }
-
- public static void init() {
- synchronized (lock) {
-
- if (OpenSSLStatus.isInitialized()) {
- return;
- }
- OpenSSLStatus.setInitialized(true);
-
- if ("off".equalsIgnoreCase(SSLEngine)) {
- return;
- }
-
- try (var memorySession = Arena.ofConfined()) {
-
- // Main library init
- initLibrary();
-
- // OpenSSL 3 onwards uses providers
- boolean isOpenSSL3 = (OpenSSL_version_num() >= 0x3000000fL);
-
- // Setup engine
- String engineName = "on".equalsIgnoreCase(SSLEngine) ? null : SSLEngine;
- if (!isOpenSSL3 && engineName != null) {
- if ("auto".equals(engineName)) {
- ENGINE_register_all_complete();
- } else {
- var engine = memorySession.allocateFrom(engineName);
- enginePointer = ENGINE_by_id(engine);
- if (MemorySegment.NULL.equals(enginePointer)) {
- enginePointer = ENGINE_by_id(memorySession.allocateFrom("dynamic"));
- if (enginePointer != null) {
- if (ENGINE_ctrl_cmd_string(enginePointer, memorySession.allocateFrom("SO_PATH"), engine, 0) == 0
- || ENGINE_ctrl_cmd_string(enginePointer, memorySession.allocateFrom("LOAD"),
- MemorySegment.NULL, 0) == 0) {
- // Engine load error
- ENGINE_free(enginePointer);
- enginePointer = MemorySegment.NULL;
- }
- }
- }
- if (!MemorySegment.NULL.equals(enginePointer)) {
- if (ENGINE_set_default(enginePointer, ENGINE_METHOD_ALL()) == 0) {
- // Engine load error
- ENGINE_free(enginePointer);
- enginePointer = MemorySegment.NULL;
- }
- }
- if (MemorySegment.NULL.equals(enginePointer)) {
- throw new IllegalStateException(sm.getString("openssllibrary.engineError"));
- }
- }
- }
-
- // Set the random seed, translated to the Java way
- boolean seedDone = false;
- if (SSLRandomSeed != null || SSLRandomSeed.length() != 0 || !"builtin".equals(SSLRandomSeed)) {
- var randomSeed = memorySession.allocateFrom(SSLRandomSeed);
- seedDone = RAND_load_file(randomSeed, 128) > 0;
- }
- if (!seedDone) {
- // Use a regular random to get some bytes
- SecureRandom random = new SecureRandom();
- byte[] randomBytes = random.generateSeed(128);
- RAND_seed(memorySession.allocateFrom(ValueLayout.JAVA_BYTE, randomBytes), 128);
- }
-
- if (!isOpenSSL3) {
- initDHParameters();
- }
-
- if (isOpenSSL3 || !(null == FIPSMode || "off".equalsIgnoreCase(FIPSMode))) {
- fipsModeActive = false;
- final boolean enterFipsMode;
- int fipsModeState = FIPS_OFF;
- if (isOpenSSL3) {
- var md = EVP_MD_fetch(MemorySegment.NULL, memorySession.allocateFrom("SHA-512"), MemorySegment.NULL);
- var provider = EVP_MD_get0_provider(md);
- String name = OSSL_PROVIDER_get0_name(provider).getString(0);
- EVP_MD_free(md);
- if ("fips".equals(name)) {
- fipsModeState = FIPS_ON;
- }
- } else {
- fipsModeState = FIPS_mode();
- }
-
- if(log.isDebugEnabled()) {
- log.debug(sm.getString("openssllibrary.currentFIPSMode", Integer.valueOf(fipsModeState)));
- }
-
- if (null == FIPSMode || "off".equalsIgnoreCase(FIPSMode)) {
- if (fipsModeState == FIPS_ON) {
- fipsModeActive = true;
- }
- enterFipsMode = false;
- } else if ("on".equalsIgnoreCase(FIPSMode)) {
- if (fipsModeState == FIPS_ON) {
- if (!isOpenSSL3) {
- log.info(sm.getString("openssllibrary.skipFIPSInitialization"));
- }
- fipsModeActive = true;
- enterFipsMode = false;
- } else {
- if (isOpenSSL3) {
- throw new IllegalStateException(sm.getString("openssllibrary.FIPSProviderNotDefault", FIPSMode));
- } else {
- enterFipsMode = true;
- }
- }
- } else if ("require".equalsIgnoreCase(FIPSMode)) {
- if (fipsModeState == FIPS_ON) {
- fipsModeActive = true;
- enterFipsMode = false;
- } else {
- if (isOpenSSL3) {
- throw new IllegalStateException(sm.getString("openssllibrary.FIPSProviderNotDefault", FIPSMode));
- } else {
- throw new IllegalStateException(sm.getString("openssllibrary.requireNotInFIPSMode"));
- }
- }
- } else if ("enter".equalsIgnoreCase(FIPSMode)) {
- if (fipsModeState == FIPS_OFF) {
- if (isOpenSSL3) {
- throw new IllegalStateException(sm.getString("openssllibrary.FIPSProviderNotDefault", FIPSMode));
- } else {
- enterFipsMode = true;
- }
- } else {
- if (isOpenSSL3) {
- fipsModeActive = true;
- enterFipsMode = false;
- } else {
- throw new IllegalStateException(sm.getString(
- "openssllibrary.enterAlreadyInFIPSMode", Integer.valueOf(fipsModeState)));
- }
- }
- } else {
- throw new IllegalArgumentException(sm.getString(
- "openssllibrary.wrongFIPSMode", FIPSMode));
- }
-
- if (enterFipsMode) {
- log.info(sm.getString("openssllibrary.initializingFIPS"));
-
- fipsModeState = FIPS_mode_set(FIPS_ON);
- if (fipsModeState != FIPS_ON) {
- // This case should be handled by the native method,
- // but we'll make absolutely sure, here.
- String message = sm.getString("openssllibrary.initializeFIPSFailed");
- log.error(message);
- throw new IllegalStateException(message);
- }
-
- fipsModeActive = true;
- log.info(sm.getString("openssllibrary.initializeFIPSSuccess"));
- }
-
- if (isOpenSSL3 && fipsModeActive) {
- log.info(sm.getString("aprListener.usingFIPSProvider"));
- }
- }
-
- log.info(sm.getString("openssllibrary.initializedOpenSSL", OpenSSL_version(0).getString(0)));
- OpenSSLStatus.setAvailable(true);
- }
- }
- }
-
-
- public static void destroy() {
- synchronized (lock) {
- if (!OpenSSLStatus.isInitialized()) {
- return;
- }
- OpenSSLStatus.setAvailable(false);
-
- try {
- if (OpenSSL_version_num() < 0x3000000fL) {
- freeDHParameters();
- if (!MemorySegment.NULL.equals(enginePointer)) {
- ENGINE_free(enginePointer);
- }
- FIPS_mode_set(0);
- }
- } finally {
- OpenSSLStatus.setInitialized(false);
- fipsModeActive = false;
- }
- }
- }
-
- public static String getSSLEngine() {
- return SSLEngine;
- }
-
- public static void setSSLEngine(String SSLEngine) {
- if (!SSLEngine.equals(OpenSSLLibrary.SSLEngine)) {
- // Ensure that the SSLEngine is consistent with that used for SSL init
- if (OpenSSLStatus.isInitialized()) {
- throw new IllegalStateException(
- sm.getString("openssllibrary.tooLateForSSLEngine"));
- }
-
- OpenSSLLibrary.SSLEngine = SSLEngine;
- }
- }
-
- public static String getSSLRandomSeed() {
- return SSLRandomSeed;
- }
-
- public static void setSSLRandomSeed(String SSLRandomSeed) {
- if (!SSLRandomSeed.equals(OpenSSLLibrary.SSLRandomSeed)) {
- // Ensure that the random seed is consistent with that used for SSL init
- if (OpenSSLStatus.isInitialized()) {
- throw new IllegalStateException(
- sm.getString("openssllibrary.tooLateForSSLRandomSeed"));
- }
-
- OpenSSLLibrary.SSLRandomSeed = SSLRandomSeed;
- }
- }
-
- public static String getFIPSMode() {
- return FIPSMode;
- }
-
- public static void setFIPSMode(String FIPSMode) {
- if (!FIPSMode.equals(OpenSSLLibrary.FIPSMode)) {
- // Ensure that the FIPS mode is consistent with that used for SSL init
- if (OpenSSLStatus.isInitialized()) {
- throw new IllegalStateException(
- sm.getString("openssllibrary.tooLateForFIPSMode"));
- }
-
- OpenSSLLibrary.FIPSMode = FIPSMode;
- }
- }
-
- public static boolean isFIPSModeActive() {
- return fipsModeActive;
- }
-
- public static List<String> findCiphers(String ciphers) {
- ArrayList<String> ciphersList = new ArrayList<>();
- try (var localArena = Arena.ofConfined()) {
- initLibrary();
- var sslCtx = SSL_CTX_new(TLS_server_method());
- try {
- SSL_CTX_set_options(sslCtx, SSL_OP_ALL());
- SSL_CTX_set_cipher_list(sslCtx, localArena.allocateFrom(ciphers));
- var ssl = SSL_new(sslCtx);
- SSL_set_accept_state(ssl);
- try {
- for (String c : getCiphers(ssl)) {
- // Filter out bad input.
- if (c == null || c.length() == 0 || ciphersList.contains(c)) {
- continue;
- }
- ciphersList.add(OpenSSLCipherConfigurationParser.openSSLToJsse(c));
- }
- } finally {
- SSL_free(ssl);
- }
- } finally {
- SSL_CTX_free(sslCtx);
- }
- } catch (Exception e) {
- log.warn(sm.getString("openssllibrary.ciphersFailure"), e);
- }
- return ciphersList;
- }
-
- static String[] getCiphers(MemorySegment ssl) {
- MemorySegment sk = SSL_get_ciphers(ssl);
- int len = OPENSSL_sk_num(sk);
- if (len <= 0) {
- return null;
- }
- ArrayList<String> ciphers = new ArrayList<>(len);
- for (int i = 0; i < len; i++) {
- MemorySegment cipher = OPENSSL_sk_value(sk, i);
- MemorySegment cipherName = SSL_CIPHER_get_name(cipher);
- ciphers.add(cipherName.getString(0));
- }
- return ciphers.toArray(new String[0]);
- }
-
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLifecycleListener.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLifecycleListener.java
deleted file mode 100644
index 2e92f01b74..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLifecycleListener.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Server;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.compat.JreCompat;
-import org.apache.tomcat.util.res.StringManager;
-
-
-
-/**
- * Implementation of <code>LifecycleListener</code> that will do the global
- * initialization of OpenSSL according to specified configuration parameters.
- * Using the listener is completely optional, but is needed for configuration
- * and full cleanup of a few native memory allocations.
- * TODO: Move to o.a.catalina.core along with AprLifecycleListener
- */
-public class OpenSSLLifecycleListener implements LifecycleListener {
-
- private static final Log log = LogFactory.getLog(OpenSSLLifecycleListener.class);
-
- /**
- * The string manager for this package.
- */
- protected static final StringManager sm = StringManager.getManager(OpenSSLLifecycleListener.class);
-
-
- // ---------------------------------------------- LifecycleListener Methods
-
- /**
- * Primary entry point for startup and shutdown events.
- *
- * @param event The event that has occurred
- */
- @Override
- public void lifecycleEvent(LifecycleEvent event) {
-
- boolean initError = false;
- if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
- if (!(event.getLifecycle() instanceof Server)) {
- log.warn(sm.getString("listener.notServer",
- event.getLifecycle().getClass().getSimpleName()));
- }
- if (!JreCompat.isJre22Available()) {
- log.warn(sm.getString("openssllistener.java22"));
- return;
- }
- try {
- OpenSSLLibrary.init();
- } catch (Throwable t) {
- t = ExceptionUtils.unwrapInvocationTargetException(t);
- ExceptionUtils.handleThrowable(t);
- log.error(sm.getString("openssllistener.sslInit"), t);
- initError = true;
- }
- // Failure to initialize FIPS mode is fatal
- if (!(null == OpenSSLLibrary.FIPSMode || "off".equalsIgnoreCase(OpenSSLLibrary.FIPSMode)) && !isFIPSModeActive()) {
- String errorMessage = sm.getString("openssllistener.initializeFIPSFailed");
- Error e = new Error(errorMessage);
- // Log here, because thrown error might be not logged
- log.fatal(errorMessage, e);
- initError = true;
- }
- }
- if (initError || Lifecycle.AFTER_DESTROY_EVENT.equals(event.getType())) {
- if (!JreCompat.isJre22Available()) {
- return;
- }
- // Note: Without the listener, destroy will never be called (which is not a significant problem)
- try {
- OpenSSLLibrary.destroy();
- } catch (Throwable t) {
- t = ExceptionUtils.unwrapInvocationTargetException(t);
- ExceptionUtils.handleThrowable(t);
- log.info(sm.getString("openssllistener.destroy"));
- }
- }
-
- }
-
- public String getSSLEngine() {
- return OpenSSLLibrary.getSSLEngine();
- }
-
- public void setSSLEngine(String SSLEngine) {
- OpenSSLLibrary.setSSLEngine(SSLEngine);
- }
-
- public String getSSLRandomSeed() {
- return OpenSSLLibrary.getSSLRandomSeed();
- }
-
- public void setSSLRandomSeed(String SSLRandomSeed) {
- OpenSSLLibrary.setSSLRandomSeed(SSLRandomSeed);
- }
-
- public String getFIPSMode() {
- return OpenSSLLibrary.getFIPSMode();
- }
-
- public void setFIPSMode(String FIPSMode) {
- OpenSSLLibrary.setFIPSMode(FIPSMode);
- }
-
- public boolean isFIPSModeActive() {
- return OpenSSLLibrary.isFIPSModeActive();
- }
-
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java
deleted file mode 100644
index 82ece562b0..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-import java.lang.foreign.Arena;
-import java.lang.foreign.ValueLayout;
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSessionContext;
-
-import static org.apache.tomcat.util.openssl.openssl_h.*;
-import static org.apache.tomcat.util.openssl.openssl_h_Macros.*;
-import org.apache.tomcat.util.res.StringManager;
-
-/**
- * OpenSSL specific {@link SSLSessionContext} implementation.
- */
-public class OpenSSLSessionContext implements SSLSessionContext {
- private static final StringManager sm = StringManager.getManager(OpenSSLSessionContext.class);
- private static final Enumeration<byte[]> EMPTY = new EmptyEnumeration();
-
- private static final int TICKET_KEYS_SIZE = 48;
-
- private final OpenSSLSessionStats stats;
- private final OpenSSLContext context;
-
- OpenSSLSessionContext(OpenSSLContext context) {
- this.context = context;
- stats = new OpenSSLSessionStats(context.getSSLContext());
- }
-
- @Override
- public SSLSession getSession(byte[] bytes) {
- return null;
- }
-
- @Override
- public Enumeration<byte[]> getIds() {
- return EMPTY;
- }
-
- /**
- * Sets the SSL session ticket keys of this context.
- *
- * @param keys The session ticket keys
- */
- public void setTicketKeys(byte[] keys) {
- if (keys == null) {
- throw new IllegalArgumentException(sm.getString("sessionContext.nullTicketKeys"));
- }
- if (keys.length != TICKET_KEYS_SIZE) {
- throw new IllegalArgumentException(sm.getString("sessionContext.invalidTicketKeysLength",
- Integer.valueOf(keys.length)));
- }
- try (var memorySession = Arena.ofConfined()) {
- var array = memorySession.allocateFrom(ValueLayout.JAVA_BYTE, keys);
- SSL_CTX_set_tlsext_ticket_keys(context.getSSLContext(), array, TICKET_KEYS_SIZE);
- }
- }
-
- /**
- * Enable or disable caching of SSL sessions.
- *
- * @param enabled {@code true} to enable caching, {@code false} to disable
- */
- public void setSessionCacheEnabled(boolean enabled) {
- long mode = enabled ? SSL_SESS_CACHE_SERVER() : SSL_SESS_CACHE_OFF();
- SSL_CTX_set_session_cache_mode(context.getSSLContext(), mode);
- }
-
- /**
- * @return {@code true} if caching of SSL sessions is enabled, {@code false}
- * otherwise.
- */
- public boolean isSessionCacheEnabled() {
- return SSL_CTX_get_session_cache_mode(context.getSSLContext()) == SSL_SESS_CACHE_SERVER();
- }
-
- /**
- * @return The statistics for this context.
- */
- public OpenSSLSessionStats stats() {
- return stats;
- }
-
- @Override
- public void setSessionTimeout(int seconds) {
- if (seconds < 0) {
- throw new IllegalArgumentException();
- }
- SSL_CTX_set_timeout(context.getSSLContext(), seconds);
- }
-
- @Override
- public int getSessionTimeout() {
- return (int) SSL_CTX_get_timeout(context.getSSLContext());
- }
-
- @Override
- public void setSessionCacheSize(int size) {
- if (size < 0) {
- throw new IllegalArgumentException();
- }
- SSL_CTX_sess_set_cache_size(context.getSSLContext(), size);
- }
-
- @Override
- public int getSessionCacheSize() {
- return (int) SSL_CTX_sess_get_cache_size(context.getSSLContext());
- }
-
- /**
- * Set the context within which session be reused (server side only)
- * See <a href="http://www.openssl.org/docs/ssl/SSL_CTX_set_session_id_context.html">
- * man SSL_CTX_set_session_id_context</a>
- *
- * @param sidCtx can be any kind of binary data, it is therefore possible to use e.g. the name
- * of the application and/or the hostname and/or service name
- * @return {@code true} if success, {@code false} otherwise.
- */
- public boolean setSessionIdContext(byte[] sidCtx) {
- try (var memorySession = Arena.ofConfined()) {
- var array = memorySession.allocateFrom(ValueLayout.JAVA_BYTE, sidCtx);
- return (SSL_CTX_set_session_id_context(context.getSSLContext(), array, sidCtx.length) == 1);
- }
- }
-
- private static final class EmptyEnumeration implements Enumeration<byte[]> {
- @Override
- public boolean hasMoreElements() {
- return false;
- }
-
- @Override
- public byte[] nextElement() {
- throw new NoSuchElementException();
- }
- }
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionStats.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionStats.java
deleted file mode 100644
index a63e524381..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionStats.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-import java.lang.foreign.MemorySegment;
-
-import static org.apache.tomcat.util.openssl.openssl_h.*;
-
-/**
- * Stats exposed by an OpenSSL session context.
- *
- * @see <a href="https://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html"><code>SSL_CTX_sess_number</code></a>
- */
-public final class OpenSSLSessionStats {
-
- private final MemorySegment ctx;
-
- OpenSSLSessionStats(MemorySegment ctx) {
- this.ctx = ctx;
- }
-
- /**
- * @return The current number of sessions in the internal session cache.
- */
- public long number() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_NUMBER(), 0, null);
- }
-
- /**
- * @return The number of started SSL/TLS handshakes in client mode.
- */
- public long connect() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CONNECT() ,0, null);
- }
-
- /**
- * @return The number of successfully established SSL/TLS sessions in client mode.
- */
- public long connectGood() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CONNECT_GOOD() , 0, null);
- }
-
- /**
- * @return The number of start renegotiations in client mode.
- */
- public long connectRenegotiate() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CONNECT_RENEGOTIATE() , 0, null);
- }
-
- /**
- * @return The number of started SSL/TLS handshakes in server mode.
- */
- public long accept() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_ACCEPT(), 0, null);
- }
-
- /**
- * @return The number of successfully established SSL/TLS sessions in server mode.
- */
- public long acceptGood() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_ACCEPT_GOOD(), 0, null);
- }
-
- /**
- * @return The number of start renegotiations in server mode.
- */
- public long acceptRenegotiate() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_ACCEPT_RENEGOTIATE(), 0, null);
- }
-
- /**
- * @return The number of successfully reused sessions. In client mode, a
- * session set with {@code SSL_set_session} successfully reused is
- * counted as a hit. In server mode, a session successfully
- * retrieved from internal or external cache is counted as a hit.
- */
- public long hits() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_HIT(), 0, null);
- }
-
- /**
- * @return The number of successfully retrieved sessions from the external
- * session cache in server mode.
- */
- public long cbHits() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CB_HIT(), 0, null);
- }
-
- /**
- * @return The number of sessions proposed by clients that were not found in
- * the internal session cache in server mode.
- */
- public long misses() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_MISSES(), 0, null);
- }
-
- /**
- * @return 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 {@link #hits()} count.
- */
- public long timeouts() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_TIMEOUTS(), 0, null);
- }
-
- /**
- * @return The number of sessions that were removed because the maximum
- * session cache size was exceeded.
- */
- public long cacheFull() {
- return SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CACHE_FULL(), 0, null);
- }
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLStatus.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLStatus.java
deleted file mode 100644
index a45f442708..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLStatus.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-/**
- * Holds OpenSSL status without the need to load other classes.
- */
-public class OpenSSLStatus {
- private static volatile boolean libraryInitialized = false;
- private static volatile boolean initialized = false;
- private static volatile boolean available = false;
- private static volatile boolean instanceCreated = false;
-
-
- public static boolean isLibraryInitialized() {
- return libraryInitialized;
- }
-
- public static boolean isInitialized() {
- return initialized;
- }
-
- public static boolean isAvailable() {
- return available;
- }
-
- public static boolean isInstanceCreated() {
- return instanceCreated;
- }
-
- public static void setLibraryInitialized(boolean libraryInitialized) {
- OpenSSLStatus.libraryInitialized = libraryInitialized;
- }
-
- public static void setInitialized(boolean initialized) {
- OpenSSLStatus.initialized = initialized;
- }
-
- public static void setAvailable(boolean available) {
- OpenSSLStatus.available = available;
- }
-
- public static void setInstanceCreated(boolean instanceCreated) {
- OpenSSLStatus.instanceCreated = instanceCreated;
- }
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLUtil.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLUtil.java
deleted file mode 100644
index 8891ba839e..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLUtil.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-import java.io.IOException;
-import java.security.KeyStoreException;
-import java.util.List;
-import java.util.Set;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.X509KeyManager;
-
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.net.SSLContext;
-import org.apache.tomcat.util.net.SSLHostConfigCertificate;
-import org.apache.tomcat.util.net.SSLUtilBase;
-import org.apache.tomcat.util.net.jsse.JSSEKeyManager;
-import org.apache.tomcat.util.res.StringManager;
-
-public class OpenSSLUtil extends SSLUtilBase {
-
- private static final Log log = LogFactory.getLog(OpenSSLUtil.class);
- private static final StringManager sm = StringManager.getManager(OpenSSLUtil.class);
-
-
- public OpenSSLUtil(SSLHostConfigCertificate certificate) {
- super(certificate);
- }
-
-
- @Override
- protected Log getLog() {
- return log;
- }
-
-
- @Override
- protected Set<String> getImplementedProtocols() {
- return OpenSSLEngine.IMPLEMENTED_PROTOCOLS_SET;
- }
-
-
- @Override
- protected Set<String> getImplementedCiphers() {
- return OpenSSLEngine.AVAILABLE_CIPHER_SUITES;
- }
-
-
- @Override
- protected boolean isTls13RenegAuthAvailable() {
- // OpenSSL does support authentication after the initial handshake
- return true;
- }
-
-
- @Override
- public SSLContext createSSLContextInternal(List<String> negotiableProtocols) throws Exception {
- return new OpenSSLContext(certificate, negotiableProtocols);
- }
-
-
- @Deprecated
- public static X509KeyManager chooseKeyManager(KeyManager[] managers) throws Exception {
- return chooseKeyManager(managers, true);
- }
-
-
- public static X509KeyManager chooseKeyManager(KeyManager[] managers, boolean throwOnMissing) throws Exception {
- if (managers == null) {
- return null;
- }
- for (KeyManager manager : managers) {
- if (manager instanceof JSSEKeyManager) {
- return (JSSEKeyManager) manager;
- }
- }
- for (KeyManager manager : managers) {
- if (manager instanceof X509KeyManager) {
- return (X509KeyManager) manager;
- }
- }
- if (throwOnMissing) {
- throw new IllegalStateException(sm.getString("openssl.keyManagerMissing"));
- }
-
- log.warn(sm.getString("openssl.keyManagerMissing.warn"));
- return null;
- }
-
-
- @Override
- public KeyManager[] getKeyManagers() throws Exception {
- try {
- return super.getKeyManagers();
- } catch (IllegalArgumentException e) {
- // No (or invalid?) certificate chain was provided for the cert
- String msg = sm.getString("openssl.nonJsseChain", certificate.getCertificateChainFile());
- if (log.isDebugEnabled()) {
- log.info(msg, e);
- } else {
- log.info(msg);
- }
- return null;
- } catch (KeyStoreException | IOException e) {
- // Depending on what is presented, JSSE may also throw
- // KeyStoreException or IOException if it doesn't understand the
- // provided file.
- if (certificate.getCertificateFile() != null) {
- String msg = sm.getString("openssl.nonJsseCertificate",
- certificate.getCertificateFile(), certificate.getCertificateKeyFile());
- if (log.isDebugEnabled()) {
- log.info(msg, e);
- } else {
- log.info(msg);
- }
- // Assume JSSE processing of the certificate failed, try again with OpenSSL
- // without a key manager
- return null;
- }
- throw e;
- }
- }
-
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLX509Certificate.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLX509Certificate.java
deleted file mode 100644
index fc52abe8d6..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLX509Certificate.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.net.openssl.panama;
-
-import java.io.ByteArrayInputStream;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateExpiredException;
-import java.security.cert.CertificateNotYetValidException;
-import java.security.cert.X509Certificate;
-import java.util.Date;
-import java.util.Set;
-
-final class OpenSSLX509Certificate extends X509Certificate {
-
- private final byte[] bytes;
- private X509Certificate wrapped;
-
- OpenSSLX509Certificate(byte[] bytes) {
- this.bytes = bytes;
- }
-
- @Override
- public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException {
- unwrap().checkValidity();
- }
-
- @Override
- public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException {
- unwrap().checkValidity(date);
- }
-
- @Override
- public int getVersion() {
- return unwrap().getVersion();
- }
-
- @Override
- public BigInteger getSerialNumber() {
- return unwrap().getSerialNumber();
- }
-
- @Override
- @Deprecated
- public Principal getIssuerDN() {
- return unwrap().getIssuerDN();
- }
-
- @Override
- @Deprecated
- public Principal getSubjectDN() {
- return unwrap().getSubjectDN();
- }
-
- @Override
- public Date getNotBefore() {
- return unwrap().getNotBefore();
- }
-
- @Override
- public Date getNotAfter() {
- return unwrap().getNotAfter();
- }
-
- @Override
- public byte[] getTBSCertificate() throws CertificateEncodingException {
- return unwrap().getTBSCertificate();
- }
-
- @Override
- public byte[] getSignature() {
- return unwrap().getSignature();
- }
-
- @Override
- public String getSigAlgName() {
- return unwrap().getSigAlgName();
- }
-
- @Override
- public String getSigAlgOID() {
- return unwrap().getSigAlgOID();
- }
-
- @Override
- public byte[] getSigAlgParams() {
- return unwrap().getSigAlgParams();
- }
-
- @Override
- public boolean[] getIssuerUniqueID() {
- return unwrap().getIssuerUniqueID();
- }
-
- @Override
- public boolean[] getSubjectUniqueID() {
- return unwrap().getSubjectUniqueID();
- }
-
- @Override
- public boolean[] getKeyUsage() {
- return unwrap().getKeyUsage();
- }
-
- @Override
- public int getBasicConstraints() {
- return unwrap().getBasicConstraints();
- }
-
- @Override
- public byte[] getEncoded() {
- return bytes.clone();
- }
-
- @Override
- public void verify(PublicKey key)
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException, SignatureException {
- unwrap().verify(key);
- }
-
- @Override
- public void verify(PublicKey key, String sigProvider)
- throws CertificateException, NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException {
- unwrap().verify(key, sigProvider);
- }
-
- @Override
- public String toString() {
- return unwrap().toString();
- }
-
- @Override
- public PublicKey getPublicKey() {
- return unwrap().getPublicKey();
- }
-
- @Override
- public boolean hasUnsupportedCriticalExtension() {
- return unwrap().hasUnsupportedCriticalExtension();
- }
-
- @Override
- public Set<String> getCriticalExtensionOIDs() {
- return unwrap().getCriticalExtensionOIDs();
- }
-
- @Override
- public Set<String> getNonCriticalExtensionOIDs() {
- return unwrap().getNonCriticalExtensionOIDs();
- }
-
- @Override
- public byte[] getExtensionValue(String oid) {
- return unwrap().getExtensionValue(oid);
- }
-
- private X509Certificate unwrap() {
- X509Certificate wrapped = this.wrapped;
- if (wrapped == null) {
- try {
- wrapped = this.wrapped = (X509Certificate) OpenSSLContext.X509_CERT_FACTORY.generateCertificate(
- new ByteArrayInputStream(bytes));
- } catch (CertificateException e) {
- throw new IllegalStateException(e);
- }
- }
- return wrapped;
- }
-}
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_alpn_select_cb$cb.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_alpn_select_cb$cb.java
deleted file mode 100644
index b216da3591..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_alpn_select_cb$cb.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Generated by jextract
-
-package org.apache.tomcat.util.openssl;
-
-import java.lang.foreign.Arena;
-import java.lang.foreign.FunctionDescriptor;
-import java.lang.foreign.Linker;
-import java.lang.foreign.MemorySegment;
-import java.lang.invoke.MethodHandle;
-
-/**
- * {@snippet lang=c :
- * SSL_CTX_alpn_select_cb_func cb
- * }
- */
-@SuppressWarnings("javadoc")
-public class SSL_CTX_set_alpn_select_cb$cb {
-
- public interface Function {
- int apply(MemorySegment _x0, MemorySegment _x1, MemorySegment _x2, MemorySegment _x3, int _x4, MemorySegment _x5);
- }
-
- private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- public static FunctionDescriptor descriptor() {
- return $DESC;
- }
-
- private static final MethodHandle UP$MH = openssl_h.upcallHandle(SSL_CTX_set_alpn_select_cb$cb.Function.class, "apply", $DESC);
-
- public static MemorySegment allocate(SSL_CTX_set_alpn_select_cb$cb.Function fi, Arena scope) {
- return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, scope);
- }
-
- private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
-
- public static int invoke(MemorySegment funcPtr,MemorySegment _x0, MemorySegment _x1, MemorySegment _x2, MemorySegment _x3, int _x4, MemorySegment _x5) {
- try {
- return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2, _x3, _x4, _x5);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-}
-
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_cert_verify_callback$cb.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_cert_verify_callback$cb.java
deleted file mode 100644
index dbd1cd77d1..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_cert_verify_callback$cb.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Generated by jextract
-
-package org.apache.tomcat.util.openssl;
-
-import java.lang.foreign.Arena;
-import java.lang.foreign.FunctionDescriptor;
-import java.lang.foreign.Linker;
-import java.lang.foreign.MemorySegment;
-import java.lang.invoke.MethodHandle;
-
-/**
- * {@snippet lang=c :
- * int (*cb)(X509_STORE_CTX *, void *)
- * }
- */
-@SuppressWarnings("javadoc")
-public class SSL_CTX_set_cert_verify_callback$cb {
-
- public interface Function {
- int apply(MemorySegment _x0, MemorySegment _x1);
- }
-
- private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- public static FunctionDescriptor descriptor() {
- return $DESC;
- }
-
- private static final MethodHandle UP$MH = openssl_h.upcallHandle(SSL_CTX_set_cert_verify_callback$cb.Function.class, "apply", $DESC);
-
- public static MemorySegment allocate(SSL_CTX_set_cert_verify_callback$cb.Function fi, Arena scope) {
- return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, scope);
- }
-
- private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
-
- public static int invoke(MemorySegment funcPtr,MemorySegment _x0, MemorySegment _x1) {
- try {
- return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-}
-
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_tmp_dh_callback$dh.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_tmp_dh_callback$dh.java
deleted file mode 100644
index ed4c8217cb..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_tmp_dh_callback$dh.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Generated by jextract
-
-package org.apache.tomcat.util.openssl;
-
-import java.lang.foreign.Arena;
-import java.lang.foreign.FunctionDescriptor;
-import java.lang.foreign.Linker;
-import java.lang.foreign.MemorySegment;
-import java.lang.invoke.MethodHandle;
-
-/**
- * {@snippet lang=c :
- * DH *(*dh)(SSL *, int, int)
- * }
- */
-@SuppressWarnings("javadoc")
-public class SSL_CTX_set_tmp_dh_callback$dh {
-
- public interface Function {
- MemorySegment apply(MemorySegment _x0, int _x1, int _x2);
- }
-
- private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_INT,
- openssl_h.C_INT
- );
-
- public static FunctionDescriptor descriptor() {
- return $DESC;
- }
-
- private static final MethodHandle UP$MH = openssl_h.upcallHandle(SSL_CTX_set_tmp_dh_callback$dh.Function.class, "apply", $DESC);
-
- public static MemorySegment allocate(SSL_CTX_set_tmp_dh_callback$dh.Function fi, Arena scope) {
- return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, scope);
- }
-
- private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
-
- public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0, int _x1, int _x2) {
- try {
- return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-}
-
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_verify$callback.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_verify$callback.java
deleted file mode 100644
index bf966a21db..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_CTX_set_verify$callback.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Generated by jextract
-
-package org.apache.tomcat.util.openssl;
-
-import java.lang.foreign.Arena;
-import java.lang.foreign.FunctionDescriptor;
-import java.lang.foreign.Linker;
-import java.lang.foreign.MemorySegment;
-import java.lang.invoke.MethodHandle;
-
-/**
- * {@snippet lang=c :
- * SSL_verify_cb callback
- * }
- */
-@SuppressWarnings("javadoc")
-public class SSL_CTX_set_verify$callback {
-
- public interface Function {
- int apply(int _x0, MemorySegment _x1);
- }
-
- private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- public static FunctionDescriptor descriptor() {
- return $DESC;
- }
-
- private static final MethodHandle UP$MH = openssl_h.upcallHandle(SSL_CTX_set_verify$callback.Function.class, "apply", $DESC);
-
- public static MemorySegment allocate(SSL_CTX_set_verify$callback.Function fi, Arena scope) {
- return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, scope);
- }
-
- private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
-
- public static int invoke(MemorySegment funcPtr,int _x0, MemorySegment _x1) {
- try {
- return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-}
-
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_set_info_callback$cb.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_set_info_callback$cb.java
deleted file mode 100644
index 226d68070c..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_set_info_callback$cb.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Generated by jextract
-
-package org.apache.tomcat.util.openssl;
-
-import java.lang.foreign.Arena;
-import java.lang.foreign.FunctionDescriptor;
-import java.lang.foreign.Linker;
-import java.lang.foreign.MemorySegment;
-import java.lang.invoke.MethodHandle;
-
-/**
- * {@snippet lang=c :
- * void (*cb)(const SSL *, int, int)
- * }
- */
-@SuppressWarnings("javadoc")
-public class SSL_set_info_callback$cb {
-
- public interface Function {
- void apply(MemorySegment _x0, int _x1, int _x2);
- }
-
- private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_INT,
- openssl_h.C_INT
- );
-
- public static FunctionDescriptor descriptor() {
- return $DESC;
- }
-
- private static final MethodHandle UP$MH = openssl_h.upcallHandle(SSL_set_info_callback$cb.Function.class, "apply", $DESC);
-
- public static MemorySegment allocate(SSL_set_info_callback$cb.Function fi, Arena scope) {
- return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, scope);
- }
-
- private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
-
- public static void invoke(MemorySegment funcPtr,MemorySegment _x0, int _x1, int _x2) {
- try {
- DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-}
-
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_set_verify$callback.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_set_verify$callback.java
deleted file mode 100644
index 5c11c2f067..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/SSL_set_verify$callback.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Generated by jextract
-
-package org.apache.tomcat.util.openssl;
-
-import java.lang.foreign.Arena;
-import java.lang.foreign.FunctionDescriptor;
-import java.lang.foreign.Linker;
-import java.lang.foreign.MemorySegment;
-import java.lang.invoke.MethodHandle;
-
-/**
- * {@snippet lang=c :
- * SSL_verify_cb callback
- * }
- */
-@SuppressWarnings("javadoc")
-public class SSL_set_verify$callback {
-
- public interface Function {
- int apply(int _x0, MemorySegment _x1);
- }
-
- private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- public static FunctionDescriptor descriptor() {
- return $DESC;
- }
-
- private static final MethodHandle UP$MH = openssl_h.upcallHandle(SSL_set_verify$callback.Function.class, "apply", $DESC);
-
- public static MemorySegment allocate(SSL_set_verify$callback.Function fi, Arena scope) {
- return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, scope);
- }
-
- private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
-
- public static int invoke(MemorySegment funcPtr,int _x0, MemorySegment _x1) {
- try {
- return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-}
-
diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/openssl_h.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/openssl_h.java
deleted file mode 100644
index 3c0dcd2046..0000000000
--- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/openssl/openssl_h.java
+++ /dev/null
@@ -1,6437 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Generated by jextract
-
-package org.apache.tomcat.util.openssl;
-
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.stream.Collectors;
-import java.lang.foreign.*;
-import static java.lang.foreign.ValueLayout.*;
-
-@SuppressWarnings({"javadoc", "boxing"})
-public class openssl_h {
-
- openssl_h() {
- // Suppresses public default constructor, ensuring non-instantiability,
- // but allows generated subclasses in same package.
- }
-
- public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN;
- public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE;
- public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT;
- public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT;
- public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG;
- public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT;
- public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE;
- public static final AddressLayout C_POINTER = ValueLayout.ADDRESS
- .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE));
- public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG;
-
- static final Arena LIBRARY_ARENA = Arena.ofAuto();
- static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls");
- static final SymbolLookup SYMBOL_LOOKUP;
- static {
- String os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
- // Note: Library loading is not portable for MacOS https://github.com/sergot/openssl/issues/81
- if (os.indexOf("mac") >= 0) {
- System.loadLibrary("ssl");
- SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup());
- } else {
- SYMBOL_LOOKUP = SymbolLookup.libraryLookup(System.mapLibraryName("ssl"), LIBRARY_ARENA)
- .or(SymbolLookup.loaderLookup())
- .or(Linker.nativeLinker().defaultLookup());
- }
- }
-
- static void traceDowncall(String name, Object... args) {
- String traceArgs = Arrays.stream(args)
- .map(Object::toString)
- .collect(Collectors.joining(", "));
- System.out.printf("%s(%s)\n", name, traceArgs);
- }
-
- static MemorySegment findOrThrow(String symbol) {
- return SYMBOL_LOOKUP.find(symbol)
- .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol));
- }
-
- static MemoryLayout[] inferVariadicLayouts(Object[] varargs) {
- MemoryLayout[] result = new MemoryLayout[varargs.length];
- for (int i = 0; i < varargs.length; i++) {
- result[i] = variadicLayout(varargs[i].getClass());
- }
- return result;
- }
-
- static MethodHandle upcallHandle(Class<?> fi, String name, FunctionDescriptor fdesc) {
- try {
- return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType());
- } catch (ReflectiveOperationException ex) {
- throw new AssertionError(ex);
- }
- }
-
- static MethodHandle downcallHandleVariadic(String name, FunctionDescriptor baseDesc, MemoryLayout[] variadicLayouts) {
- FunctionDescriptor variadicDesc = baseDesc.appendArgumentLayouts(variadicLayouts);
- Linker.Option fva = Linker.Option.firstVariadicArg(baseDesc.argumentLayouts().size());
- return SYMBOL_LOOKUP.find(name)
- .map(addr -> Linker.nativeLinker().downcallHandle(addr, variadicDesc, fva)
- .asSpreader(Object[].class, variadicLayouts.length))
- .orElse(null);
- }
-
- // Internals only below this point
-
- private static MemoryLayout variadicLayout(Class<?> c) {
- // apply default argument promotions per C spec
- // note that all primitives are boxed, since they are passed through an Object[]
- if (c == Boolean.class || c == Byte.class || c == Character.class || c == Short.class || c == Integer.class) {
- return JAVA_INT;
- } else if (c == Long.class) {
- return JAVA_LONG;
- } else if (c == Float.class || c == Double.class) {
- return JAVA_DOUBLE;
- } else if (MemorySegment.class.isAssignableFrom(c)) {
- return ADDRESS;
- }
- throw new IllegalArgumentException("Invalid type for ABI: " + c.getTypeName());
- }
- private static final int BIO_CLOSE = (int)1L;
- /**
- * {@snippet lang=c :
- * #define BIO_CLOSE 1
- * }
- */
- public static int BIO_CLOSE() {
- return BIO_CLOSE;
- }
- private static final int BIO_CTRL_RESET = (int)1L;
- /**
- * {@snippet lang=c :
- * #define BIO_CTRL_RESET 1
- * }
- */
- public static int BIO_CTRL_RESET() {
- return BIO_CTRL_RESET;
- }
- private static final int BIO_FP_READ = (int)2L;
- /**
- * {@snippet lang=c :
- * #define BIO_FP_READ 2
- * }
- */
- public static int BIO_FP_READ() {
- return BIO_FP_READ;
- }
- private static final int BIO_C_SET_FILENAME = (int)108L;
- /**
- * {@snippet lang=c :
- * #define BIO_C_SET_FILENAME 108
- * }
- */
- public static int BIO_C_SET_FILENAME() {
- return BIO_C_SET_FILENAME;
- }
- private static final int NID_info_access = (int)177L;
- /**
- * {@snippet lang=c :
- * #define NID_info_access 177
- * }
- */
- public static int NID_info_access() {
- return NID_info_access;
- }
- private static final int X509_FILETYPE_PEM = (int)1L;
- /**
- * {@snippet lang=c :
- * #define X509_FILETYPE_PEM 1
- * }
- */
- public static int X509_FILETYPE_PEM() {
- return X509_FILETYPE_PEM;
- }
- private static final int X509_L_FILE_LOAD = (int)1L;
- /**
- * {@snippet lang=c :
- * #define X509_L_FILE_LOAD 1
- * }
- */
- public static int X509_L_FILE_LOAD() {
- return X509_L_FILE_LOAD;
- }
- private static final int X509_L_ADD_DIR = (int)2L;
- /**
- * {@snippet lang=c :
- * #define X509_L_ADD_DIR 2
- * }
- */
- public static int X509_L_ADD_DIR() {
- return X509_L_ADD_DIR;
- }
- private static final int X509_V_OK = (int)0L;
- /**
- * {@snippet lang=c :
- * #define X509_V_OK 0
- * }
- */
- public static int X509_V_OK() {
- return X509_V_OK;
- }
- private static final int X509_V_ERR_CRL_HAS_EXPIRED = (int)12L;
- /**
- * {@snippet lang=c :
- * #define X509_V_ERR_CRL_HAS_EXPIRED 12
- * }
- */
- public static int X509_V_ERR_CRL_HAS_EXPIRED() {
- return X509_V_ERR_CRL_HAS_EXPIRED;
- }
- private static final int X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = (int)18L;
- /**
- * {@snippet lang=c :
- * #define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18
- * }
- */
- public static int X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT() {
- return X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT;
- }
- private static final int X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = (int)19L;
- /**
- * {@snippet lang=c :
- * #define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19
- * }
- */
- public static int X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN() {
- return X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN;
- }
- private static final int X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = (int)20L;
- /**
- * {@snippet lang=c :
- * #define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20
- * }
- */
- public static int X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY() {
- return X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY;
- }
- private static final int X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = (int)21L;
- /**
- * {@snippet lang=c :
- * #define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21
- * }
- */
- public static int X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE() {
- return X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;
- }
- private static final int X509_V_ERR_CERT_UNTRUSTED = (int)27L;
- /**
- * {@snippet lang=c :
- * #define X509_V_ERR_CERT_UNTRUSTED 27
- * }
- */
- public static int X509_V_ERR_CERT_UNTRUSTED() {
- return X509_V_ERR_CERT_UNTRUSTED;
- }
- private static final int X509_V_ERR_APPLICATION_VERIFICATION = (int)50L;
- /**
- * {@snippet lang=c :
- * #define X509_V_ERR_APPLICATION_VERIFICATION 50
- * }
- */
- public static int X509_V_ERR_APPLICATION_VERIFICATION() {
- return X509_V_ERR_APPLICATION_VERIFICATION;
- }
- private static final int X509_V_FLAG_CRL_CHECK = (int)4L;
- /**
- * {@snippet lang=c :
- * #define X509_V_FLAG_CRL_CHECK 4
- * }
- */
- public static int X509_V_FLAG_CRL_CHECK() {
- return X509_V_FLAG_CRL_CHECK;
- }
- private static final int X509_V_FLAG_CRL_CHECK_ALL = (int)8L;
- /**
- * {@snippet lang=c :
- * #define X509_V_FLAG_CRL_CHECK_ALL 8
- * }
- */
- public static int X509_V_FLAG_CRL_CHECK_ALL() {
- return X509_V_FLAG_CRL_CHECK_ALL;
- }
- private static final int PEM_R_NO_START_LINE = (int)108L;
- /**
- * {@snippet lang=c :
- * #define PEM_R_NO_START_LINE 108
- * }
- */
- public static int PEM_R_NO_START_LINE() {
- return PEM_R_NO_START_LINE;
- }
- private static final int SSL3_VERSION = (int)768L;
- /**
- * {@snippet lang=c :
- * #define SSL3_VERSION 768
- * }
- */
- public static int SSL3_VERSION() {
- return SSL3_VERSION;
- }
- private static final int TLS1_VERSION = (int)769L;
- /**
- * {@snippet lang=c :
- * #define TLS1_VERSION 769
- * }
- */
- public static int TLS1_VERSION() {
- return TLS1_VERSION;
- }
- private static final int TLS1_1_VERSION = (int)770L;
- /**
- * {@snippet lang=c :
- * #define TLS1_1_VERSION 770
- * }
- */
- public static int TLS1_1_VERSION() {
- return TLS1_1_VERSION;
- }
- private static final int TLS1_2_VERSION = (int)771L;
- /**
- * {@snippet lang=c :
- * #define TLS1_2_VERSION 771
- * }
- */
- public static int TLS1_2_VERSION() {
- return TLS1_2_VERSION;
- }
- private static final int TLS1_3_VERSION = (int)772L;
- /**
- * {@snippet lang=c :
- * #define TLS1_3_VERSION 772
- * }
- */
- public static int TLS1_3_VERSION() {
- return TLS1_3_VERSION;
- }
- private static final int SSL_SENT_SHUTDOWN = (int)1L;
- /**
- * {@snippet lang=c :
- * #define SSL_SENT_SHUTDOWN 1
- * }
- */
- public static int SSL_SENT_SHUTDOWN() {
- return SSL_SENT_SHUTDOWN;
- }
- private static final int SSL_RECEIVED_SHUTDOWN = (int)2L;
- /**
- * {@snippet lang=c :
- * #define SSL_RECEIVED_SHUTDOWN 2
- * }
- */
- public static int SSL_RECEIVED_SHUTDOWN() {
- return SSL_RECEIVED_SHUTDOWN;
- }
- private static final int SSL_OP_SINGLE_ECDH_USE = (int)0L;
- /**
- * {@snippet lang=c :
- * #define SSL_OP_SINGLE_ECDH_USE 0
- * }
- */
- public static int SSL_OP_SINGLE_ECDH_USE() {
- return SSL_OP_SINGLE_ECDH_USE;
- }
- private static final int SSL_OP_SINGLE_DH_USE = (int)0L;
- /**
- * {@snippet lang=c :
- * #define SSL_OP_SINGLE_DH_USE 0
- * }
- */
- public static int SSL_OP_SINGLE_DH_USE() {
- return SSL_OP_SINGLE_DH_USE;
- }
- private static final int SSL_OP_NO_SSLv2 = (int)0L;
- /**
- * {@snippet lang=c :
- * #define SSL_OP_NO_SSLv2 0
- * }
- */
- public static int SSL_OP_NO_SSLv2() {
- return SSL_OP_NO_SSLv2;
- }
- private static final int SSL_CONF_FLAG_FILE = (int)2L;
- /**
- * {@snippet lang=c :
- * #define SSL_CONF_FLAG_FILE 2
- * }
- */
- public static int SSL_CONF_FLAG_FILE() {
- return SSL_CONF_FLAG_FILE;
- }
- private static final int SSL_CONF_FLAG_SERVER = (int)8L;
- /**
- * {@snippet lang=c :
- * #define SSL_CONF_FLAG_SERVER 8
- * }
- */
- public static int SSL_CONF_FLAG_SERVER() {
- return SSL_CONF_FLAG_SERVER;
- }
- private static final int SSL_CONF_FLAG_SHOW_ERRORS = (int)16L;
- /**
- * {@snippet lang=c :
- * #define SSL_CONF_FLAG_SHOW_ERRORS 16
- * }
- */
- public static int SSL_CONF_FLAG_SHOW_ERRORS() {
- return SSL_CONF_FLAG_SHOW_ERRORS;
- }
- private static final int SSL_CONF_FLAG_CERTIFICATE = (int)32L;
- /**
- * {@snippet lang=c :
- * #define SSL_CONF_FLAG_CERTIFICATE 32
- * }
- */
- public static int SSL_CONF_FLAG_CERTIFICATE() {
- return SSL_CONF_FLAG_CERTIFICATE;
- }
- private static final int SSL_CONF_TYPE_UNKNOWN = (int)0L;
- /**
- * {@snippet lang=c :
- * #define SSL_CONF_TYPE_UNKNOWN 0
- * }
- */
- public static int SSL_CONF_TYPE_UNKNOWN() {
- return SSL_CONF_TYPE_UNKNOWN;
- }
- private static final int SSL_CONF_TYPE_FILE = (int)2L;
- /**
- * {@snippet lang=c :
- * #define SSL_CONF_TYPE_FILE 2
- * }
- */
- public static int SSL_CONF_TYPE_FILE() {
- return SSL_CONF_TYPE_FILE;
- }
- private static final int SSL_CONF_TYPE_DIR = (int)3L;
- /**
- * {@snippet lang=c :
- * #define SSL_CONF_TYPE_DIR 3
- * }
- */
- public static int SSL_CONF_TYPE_DIR() {
- return SSL_CONF_TYPE_DIR;
- }
- private static final int SSL_SESS_CACHE_OFF = (int)0L;
- /**
- * {@snippet lang=c :
- * #define SSL_SESS_CACHE_OFF 0
- * }
- */
- public static int SSL_SESS_CACHE_OFF() {
- return SSL_SESS_CACHE_OFF;
- }
- private static final int SSL_SESS_CACHE_SERVER = (int)2L;
- /**
- * {@snippet lang=c :
- * #define SSL_SESS_CACHE_SERVER 2
- * }
- */
- public static int SSL_SESS_CACHE_SERVER() {
- return SSL_SESS_CACHE_SERVER;
- }
- private static final int SSL2_VERSION = (int)2L;
- /**
- * {@snippet lang=c :
- * #define SSL2_VERSION 2
- * }
- */
- public static int SSL2_VERSION() {
- return SSL2_VERSION;
- }
- private static final int SSL_TLSEXT_ERR_OK = (int)0L;
- /**
- * {@snippet lang=c :
- * #define SSL_TLSEXT_ERR_OK 0
- * }
- */
- public static int SSL_TLSEXT_ERR_OK() {
- return SSL_TLSEXT_ERR_OK;
- }
- private static final int SSL_TLSEXT_ERR_NOACK = (int)3L;
- /**
- * {@snippet lang=c :
- * #define SSL_TLSEXT_ERR_NOACK 3
- * }
- */
- public static int SSL_TLSEXT_ERR_NOACK() {
- return SSL_TLSEXT_ERR_NOACK;
- }
- private static final int SSL_CB_HANDSHAKE_DONE = (int)32L;
- /**
- * {@snippet lang=c :
- * #define SSL_CB_HANDSHAKE_DONE 32
- * }
- */
- public static int SSL_CB_HANDSHAKE_DONE() {
- return SSL_CB_HANDSHAKE_DONE;
- }
- private static final int SSL_VERIFY_NONE = (int)0L;
- /**
- * {@snippet lang=c :
- * #define SSL_VERIFY_NONE 0
- * }
- */
- public static int SSL_VERIFY_NONE() {
- return SSL_VERIFY_NONE;
- }
- private static final int SSL_VERIFY_PEER = (int)1L;
- /**
- * {@snippet lang=c :
- * #define SSL_VERIFY_PEER 1
- * }
- */
- public static int SSL_VERIFY_PEER() {
- return SSL_VERIFY_PEER;
- }
- private static final int SSL_VERIFY_FAIL_IF_NO_PEER_CERT = (int)2L;
- /**
- * {@snippet lang=c :
- * #define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 2
- * }
- */
- public static int SSL_VERIFY_FAIL_IF_NO_PEER_CERT() {
- return SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
- }
- private static final int SSL_ERROR_NONE = (int)0L;
- /**
- * {@snippet lang=c :
- * #define SSL_ERROR_NONE 0
- * }
- */
- public static int SSL_ERROR_NONE() {
- return SSL_ERROR_NONE;
- }
- private static final int SSL_CTRL_SET_TMP_DH = (int)3L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SET_TMP_DH 3
- * }
- */
- public static int SSL_CTRL_SET_TMP_DH() {
- return SSL_CTRL_SET_TMP_DH;
- }
- private static final int SSL_CTRL_SET_TMP_ECDH = (int)4L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SET_TMP_ECDH 4
- * }
- */
- public static int SSL_CTRL_SET_TMP_ECDH() {
- return SSL_CTRL_SET_TMP_ECDH;
- }
- private static final int SSL_CTRL_SESS_NUMBER = (int)20L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_NUMBER 20
- * }
- */
- public static int SSL_CTRL_SESS_NUMBER() {
- return SSL_CTRL_SESS_NUMBER;
- }
- private static final int SSL_CTRL_SESS_CONNECT = (int)21L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_CONNECT 21
- * }
- */
- public static int SSL_CTRL_SESS_CONNECT() {
- return SSL_CTRL_SESS_CONNECT;
- }
- private static final int SSL_CTRL_SESS_CONNECT_GOOD = (int)22L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_CONNECT_GOOD 22
- * }
- */
- public static int SSL_CTRL_SESS_CONNECT_GOOD() {
- return SSL_CTRL_SESS_CONNECT_GOOD;
- }
- private static final int SSL_CTRL_SESS_CONNECT_RENEGOTIATE = (int)23L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23
- * }
- */
- public static int SSL_CTRL_SESS_CONNECT_RENEGOTIATE() {
- return SSL_CTRL_SESS_CONNECT_RENEGOTIATE;
- }
- private static final int SSL_CTRL_SESS_ACCEPT = (int)24L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_ACCEPT 24
- * }
- */
- public static int SSL_CTRL_SESS_ACCEPT() {
- return SSL_CTRL_SESS_ACCEPT;
- }
- private static final int SSL_CTRL_SESS_ACCEPT_GOOD = (int)25L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_ACCEPT_GOOD 25
- * }
- */
- public static int SSL_CTRL_SESS_ACCEPT_GOOD() {
- return SSL_CTRL_SESS_ACCEPT_GOOD;
- }
- private static final int SSL_CTRL_SESS_ACCEPT_RENEGOTIATE = (int)26L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26
- * }
- */
- public static int SSL_CTRL_SESS_ACCEPT_RENEGOTIATE() {
- return SSL_CTRL_SESS_ACCEPT_RENEGOTIATE;
- }
- private static final int SSL_CTRL_SESS_HIT = (int)27L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_HIT 27
- * }
- */
- public static int SSL_CTRL_SESS_HIT() {
- return SSL_CTRL_SESS_HIT;
- }
- private static final int SSL_CTRL_SESS_CB_HIT = (int)28L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_CB_HIT 28
- * }
- */
- public static int SSL_CTRL_SESS_CB_HIT() {
- return SSL_CTRL_SESS_CB_HIT;
- }
- private static final int SSL_CTRL_SESS_MISSES = (int)29L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_MISSES 29
- * }
- */
- public static int SSL_CTRL_SESS_MISSES() {
- return SSL_CTRL_SESS_MISSES;
- }
- private static final int SSL_CTRL_SESS_TIMEOUTS = (int)30L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_TIMEOUTS 30
- * }
- */
- public static int SSL_CTRL_SESS_TIMEOUTS() {
- return SSL_CTRL_SESS_TIMEOUTS;
- }
- private static final int SSL_CTRL_SESS_CACHE_FULL = (int)31L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SESS_CACHE_FULL 31
- * }
- */
- public static int SSL_CTRL_SESS_CACHE_FULL() {
- return SSL_CTRL_SESS_CACHE_FULL;
- }
- private static final int SSL_CTRL_SET_SESS_CACHE_SIZE = (int)42L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SET_SESS_CACHE_SIZE 42
- * }
- */
- public static int SSL_CTRL_SET_SESS_CACHE_SIZE() {
- return SSL_CTRL_SET_SESS_CACHE_SIZE;
- }
- private static final int SSL_CTRL_GET_SESS_CACHE_SIZE = (int)43L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_GET_SESS_CACHE_SIZE 43
- * }
- */
- public static int SSL_CTRL_GET_SESS_CACHE_SIZE() {
- return SSL_CTRL_GET_SESS_CACHE_SIZE;
- }
- private static final int SSL_CTRL_SET_SESS_CACHE_MODE = (int)44L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SET_SESS_CACHE_MODE 44
- * }
- */
- public static int SSL_CTRL_SET_SESS_CACHE_MODE() {
- return SSL_CTRL_SET_SESS_CACHE_MODE;
- }
- private static final int SSL_CTRL_GET_SESS_CACHE_MODE = (int)45L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_GET_SESS_CACHE_MODE 45
- * }
- */
- public static int SSL_CTRL_GET_SESS_CACHE_MODE() {
- return SSL_CTRL_GET_SESS_CACHE_MODE;
- }
- private static final int SSL_CTRL_SET_TLSEXT_TICKET_KEYS = (int)59L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SET_TLSEXT_TICKET_KEYS 59
- * }
- */
- public static int SSL_CTRL_SET_TLSEXT_TICKET_KEYS() {
- return SSL_CTRL_SET_TLSEXT_TICKET_KEYS;
- }
- private static final int SSL_CTRL_CHAIN_CERT = (int)89L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_CHAIN_CERT 89
- * }
- */
- public static int SSL_CTRL_CHAIN_CERT() {
- return SSL_CTRL_CHAIN_CERT;
- }
- private static final int SSL_CTRL_SET_GROUPS = (int)91L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SET_GROUPS 91
- * }
- */
- public static int SSL_CTRL_SET_GROUPS() {
- return SSL_CTRL_SET_GROUPS;
- }
- private static final int SSL_CTRL_SET_DH_AUTO = (int)118L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SET_DH_AUTO 118
- * }
- */
- public static int SSL_CTRL_SET_DH_AUTO() {
- return SSL_CTRL_SET_DH_AUTO;
- }
- private static final int SSL_CTRL_SET_MIN_PROTO_VERSION = (int)123L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SET_MIN_PROTO_VERSION 123
- * }
- */
- public static int SSL_CTRL_SET_MIN_PROTO_VERSION() {
- return SSL_CTRL_SET_MIN_PROTO_VERSION;
- }
- private static final int SSL_CTRL_SET_MAX_PROTO_VERSION = (int)124L;
- /**
- * {@snippet lang=c :
- * #define SSL_CTRL_SET_MAX_PROTO_VERSION 124
- * }
- */
- public static int SSL_CTRL_SET_MAX_PROTO_VERSION() {
- return SSL_CTRL_SET_MAX_PROTO_VERSION;
- }
- private static final int ERR_REASON_MASK = (int)8388607L;
- /**
- * {@snippet lang=c :
- * #define ERR_REASON_MASK 8388607
- * }
- */
- public static int ERR_REASON_MASK() {
- return ERR_REASON_MASK;
- }
- private static final int OCSP_RESPONSE_STATUS_SUCCESSFUL = (int)0L;
- /**
- * {@snippet lang=c :
- * #define OCSP_RESPONSE_STATUS_SUCCESSFUL 0
- * }
- */
- public static int OCSP_RESPONSE_STATUS_SUCCESSFUL() {
- return OCSP_RESPONSE_STATUS_SUCCESSFUL;
- }
- private static final int V_OCSP_CERTSTATUS_GOOD = (int)0L;
- /**
- * {@snippet lang=c :
- * #define V_OCSP_CERTSTATUS_GOOD 0
- * }
- */
- public static int V_OCSP_CERTSTATUS_GOOD() {
- return V_OCSP_CERTSTATUS_GOOD;
- }
- private static final int V_OCSP_CERTSTATUS_REVOKED = (int)1L;
- /**
- * {@snippet lang=c :
- * #define V_OCSP_CERTSTATUS_REVOKED 1
- * }
- */
- public static int V_OCSP_CERTSTATUS_REVOKED() {
- return V_OCSP_CERTSTATUS_REVOKED;
- }
- private static final int V_OCSP_CERTSTATUS_UNKNOWN = (int)2L;
- /**
- * {@snippet lang=c :
- * #define V_OCSP_CERTSTATUS_UNKNOWN 2
- * }
- */
- public static int V_OCSP_CERTSTATUS_UNKNOWN() {
- return V_OCSP_CERTSTATUS_UNKNOWN;
- }
-
- private static MethodHandle OPENSSL_sk_num$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("OPENSSL_sk_num"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int OPENSSL_sk_num(const OPENSSL_STACK *)
- * }
- */
- public static int OPENSSL_sk_num(MemorySegment x0) {
- var mh$ = OPENSSL_sk_num$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("OPENSSL_sk_num", x0);
- }
- return (int) mh$.invokeExact(x0);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle OPENSSL_sk_value$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("OPENSSL_sk_value"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void *OPENSSL_sk_value(const OPENSSL_STACK *, int)
- * }
- */
- public static MemorySegment OPENSSL_sk_value(MemorySegment x0, int x1) {
- var mh$ = OPENSSL_sk_value$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("OPENSSL_sk_value", x0, x1);
- }
- return (MemorySegment) mh$.invokeExact(x0, x1);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle OpenSSL_version_num$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("OpenSSL_version_num"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * unsigned long OpenSSL_version_num(void)
- * }
- */
- public static long OpenSSL_version_num() {
- var mh$ = OpenSSL_version_num$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("OpenSSL_version_num");
- }
- return (long) mh$.invokeExact();
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle OpenSSL_version$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("OpenSSL_version"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * const char *OpenSSL_version(int type)
- * }
- */
- public static MemorySegment OpenSSL_version(int type) {
- var mh$ = OpenSSL_version$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("OpenSSL_version", type);
- }
- return (MemorySegment) mh$.invokeExact(type);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle CRYPTO_free$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("CRYPTO_free"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void CRYPTO_free(void *ptr, const char *file, int line)
- * }
- */
- public static void CRYPTO_free(MemorySegment ptr, MemorySegment file, int line) {
- var mh$ = CRYPTO_free$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("CRYPTO_free", ptr, file, line);
- }
- mh$.invokeExact(ptr, file, line);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_ctrl_pending$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_ctrl_pending"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * size_t BIO_ctrl_pending(BIO *b)
- * }
- */
- public static long BIO_ctrl_pending(MemorySegment b) {
- var mh$ = BIO_ctrl_pending$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_ctrl_pending", b);
- }
- return (long) mh$.invokeExact(b);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_s_file$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_s_file"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * const BIO_METHOD *BIO_s_file(void)
- * }
- */
- public static MemorySegment BIO_s_file() {
- var mh$ = BIO_s_file$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_s_file");
- }
- return (MemorySegment) mh$.invokeExact();
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_new_file$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_new_file"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIO *BIO_new_file(const char *filename, const char *mode)
- * }
- */
- public static MemorySegment BIO_new_file(MemorySegment filename, MemorySegment mode) {
- var mh$ = BIO_new_file$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_new_file", filename, mode);
- }
- return (MemorySegment) mh$.invokeExact(filename, mode);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_new$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_new"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIO *BIO_new(const BIO_METHOD *type)
- * }
- */
- public static MemorySegment BIO_new(MemorySegment type) {
- var mh$ = BIO_new$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_new", type);
- }
- return (MemorySegment) mh$.invokeExact(type);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_free$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_free"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int BIO_free(BIO *a)
- * }
- */
- public static int BIO_free(MemorySegment a) {
- var mh$ = BIO_free$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_free", a);
- }
- return (int) mh$.invokeExact(a);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_read$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_read"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int BIO_read(BIO *b, void *data, int dlen)
- * }
- */
- public static int BIO_read(MemorySegment b, MemorySegment data, int dlen) {
- var mh$ = BIO_read$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_read", b, data, dlen);
- }
- return (int) mh$.invokeExact(b, data, dlen);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_write$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_write"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int BIO_write(BIO *b, const void *data, int dlen)
- * }
- */
- public static int BIO_write(MemorySegment b, MemorySegment data, int dlen) {
- var mh$ = BIO_write$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_write", b, data, dlen);
- }
- return (int) mh$.invokeExact(b, data, dlen);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_ctrl$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER,
- openssl_h.C_INT,
- openssl_h.C_LONG,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_ctrl"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg)
- * }
- */
- public static long BIO_ctrl(MemorySegment bp, int cmd, long larg, MemorySegment parg) {
- var mh$ = BIO_ctrl$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_ctrl", bp, cmd, larg, parg);
- }
- return (long) mh$.invokeExact(bp, cmd, larg, parg);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_s_mem$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_s_mem"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * const BIO_METHOD *BIO_s_mem(void)
- * }
- */
- public static MemorySegment BIO_s_mem() {
- var mh$ = BIO_s_mem$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_s_mem");
- }
- return (MemorySegment) mh$.invokeExact();
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_s_bio$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_s_bio"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * const BIO_METHOD *BIO_s_bio(void)
- * }
- */
- public static MemorySegment BIO_s_bio() {
- var mh$ = BIO_s_bio$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_s_bio");
- }
- return (MemorySegment) mh$.invokeExact();
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BIO_new_bio_pair$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_LONG,
- openssl_h.C_POINTER,
- openssl_h.C_LONG
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BIO_new_bio_pair"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2)
- * }
- */
- public static int BIO_new_bio_pair(MemorySegment bio1, long writebuf1, MemorySegment bio2, long writebuf2) {
- var mh$ = BIO_new_bio_pair$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BIO_new_bio_pair", bio1, writebuf1, bio2, writebuf2);
- }
- return (int) mh$.invokeExact(bio1, writebuf1, bio2, writebuf2);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_new$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_new"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIGNUM *BN_new(void)
- * }
- */
- public static MemorySegment BN_new() {
- var mh$ = BN_new$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_new");
- }
- return (MemorySegment) mh$.invokeExact();
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_set_word$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_LONG
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_set_word"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int BN_set_word(BIGNUM *a, unsigned long w)
- * }
- */
- public static int BN_set_word(MemorySegment a, long w) {
- var mh$ = BN_set_word$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_set_word", a, w);
- }
- return (int) mh$.invokeExact(a, w);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_get_rfc2409_prime_768$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_get_rfc2409_prime_768"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn)
- * }
- */
- public static MemorySegment BN_get_rfc2409_prime_768(MemorySegment bn) {
- var mh$ = BN_get_rfc2409_prime_768$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_get_rfc2409_prime_768", bn);
- }
- return (MemorySegment) mh$.invokeExact(bn);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_get_rfc2409_prime_1024$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_get_rfc2409_prime_1024"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn)
- * }
- */
- public static MemorySegment BN_get_rfc2409_prime_1024(MemorySegment bn) {
- var mh$ = BN_get_rfc2409_prime_1024$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_get_rfc2409_prime_1024", bn);
- }
- return (MemorySegment) mh$.invokeExact(bn);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_get_rfc3526_prime_1536$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_get_rfc3526_prime_1536"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn)
- * }
- */
- public static MemorySegment BN_get_rfc3526_prime_1536(MemorySegment bn) {
- var mh$ = BN_get_rfc3526_prime_1536$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_get_rfc3526_prime_1536", bn);
- }
- return (MemorySegment) mh$.invokeExact(bn);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_get_rfc3526_prime_2048$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_get_rfc3526_prime_2048"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn)
- * }
- */
- public static MemorySegment BN_get_rfc3526_prime_2048(MemorySegment bn) {
- var mh$ = BN_get_rfc3526_prime_2048$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_get_rfc3526_prime_2048", bn);
- }
- return (MemorySegment) mh$.invokeExact(bn);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_get_rfc3526_prime_3072$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_get_rfc3526_prime_3072"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn)
- * }
- */
- public static MemorySegment BN_get_rfc3526_prime_3072(MemorySegment bn) {
- var mh$ = BN_get_rfc3526_prime_3072$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_get_rfc3526_prime_3072", bn);
- }
- return (MemorySegment) mh$.invokeExact(bn);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_get_rfc3526_prime_4096$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_get_rfc3526_prime_4096"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn)
- * }
- */
- public static MemorySegment BN_get_rfc3526_prime_4096(MemorySegment bn) {
- var mh$ = BN_get_rfc3526_prime_4096$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_get_rfc3526_prime_4096", bn);
- }
- return (MemorySegment) mh$.invokeExact(bn);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_get_rfc3526_prime_6144$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_get_rfc3526_prime_6144"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn)
- * }
- */
- public static MemorySegment BN_get_rfc3526_prime_6144(MemorySegment bn) {
- var mh$ = BN_get_rfc3526_prime_6144$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_get_rfc3526_prime_6144", bn);
- }
- return (MemorySegment) mh$.invokeExact(bn);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle BN_get_rfc3526_prime_8192$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("BN_get_rfc3526_prime_8192"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn)
- * }
- */
- public static MemorySegment BN_get_rfc3526_prime_8192(MemorySegment bn) {
- var mh$ = BN_get_rfc3526_prime_8192$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("BN_get_rfc3526_prime_8192", bn);
- }
- return (MemorySegment) mh$.invokeExact(bn);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle ASN1_STRING_length$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("ASN1_STRING_length"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int ASN1_STRING_length(const ASN1_STRING *x)
- * }
- */
- public static int ASN1_STRING_length(MemorySegment x) {
- var mh$ = ASN1_STRING_length$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("ASN1_STRING_length", x);
- }
- return (int) mh$.invokeExact(x);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle ASN1_STRING_get0_data$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("ASN1_STRING_get0_data"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x)
- * }
- */
- public static MemorySegment ASN1_STRING_get0_data(MemorySegment x) {
- var mh$ = ASN1_STRING_get0_data$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("ASN1_STRING_get0_data", x);
- }
- return (MemorySegment) mh$.invokeExact(x);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EVP_MD_get0_provider$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EVP_MD_get0_provider"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * const OSSL_PROVIDER *EVP_MD_get0_provider(const EVP_MD *md)
- * }
- */
- public static MemorySegment EVP_MD_get0_provider(MemorySegment md) {
- var mh$ = EVP_MD_get0_provider$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EVP_MD_get0_provider", md);
- }
- return (MemorySegment) mh$.invokeExact(md);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EVP_MD_fetch$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EVP_MD_fetch"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * EVP_MD *EVP_MD_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties)
- * }
- */
- public static MemorySegment EVP_MD_fetch(MemorySegment ctx, MemorySegment algorithm, MemorySegment properties) {
- var mh$ = EVP_MD_fetch$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EVP_MD_fetch", ctx, algorithm, properties);
- }
- return (MemorySegment) mh$.invokeExact(ctx, algorithm, properties);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EVP_MD_free$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EVP_MD_free"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void EVP_MD_free(EVP_MD *md)
- * }
- */
- public static void EVP_MD_free(MemorySegment md) {
- var mh$ = EVP_MD_free$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EVP_MD_free", md);
- }
- mh$.invokeExact(md);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EVP_PKEY_get_base_id$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EVP_PKEY_get_base_id"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int EVP_PKEY_get_base_id(const EVP_PKEY *pkey)
- * }
- */
- public static int EVP_PKEY_get_base_id(MemorySegment pkey) {
- var mh$ = EVP_PKEY_get_base_id$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EVP_PKEY_get_base_id", pkey);
- }
- return (int) mh$.invokeExact(pkey);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EVP_PKEY_get_bits$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EVP_PKEY_get_bits"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int EVP_PKEY_get_bits(const EVP_PKEY *pkey)
- * }
- */
- public static int EVP_PKEY_get_bits(MemorySegment pkey) {
- var mh$ = EVP_PKEY_get_bits$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EVP_PKEY_get_bits", pkey);
- }
- return (int) mh$.invokeExact(pkey);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EVP_PKEY_free$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EVP_PKEY_free"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void EVP_PKEY_free(EVP_PKEY *pkey)
- * }
- */
- public static void EVP_PKEY_free(MemorySegment pkey) {
- var mh$ = EVP_PKEY_free$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EVP_PKEY_free", pkey);
- }
- mh$.invokeExact(pkey);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EC_GROUP_free$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EC_GROUP_free"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void EC_GROUP_free(EC_GROUP *group)
- * }
- */
- public static void EC_GROUP_free(MemorySegment group) {
- var mh$ = EC_GROUP_free$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EC_GROUP_free", group);
- }
- mh$.invokeExact(group);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EC_GROUP_get_curve_name$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EC_GROUP_get_curve_name"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int EC_GROUP_get_curve_name(const EC_GROUP *group)
- * }
- */
- public static int EC_GROUP_get_curve_name(MemorySegment group) {
- var mh$ = EC_GROUP_get_curve_name$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EC_GROUP_get_curve_name", group);
- }
- return (int) mh$.invokeExact(group);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle d2i_ECPKParameters$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_LONG
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("d2i_ECPKParameters"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len)
- * }
- */
- public static MemorySegment d2i_ECPKParameters(MemorySegment x0, MemorySegment in, long len) {
- var mh$ = d2i_ECPKParameters$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("d2i_ECPKParameters", x0, in, len);
- }
- return (MemorySegment) mh$.invokeExact(x0, in, len);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EC_KEY_new_by_curve_name$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EC_KEY_new_by_curve_name"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * EC_KEY *EC_KEY_new_by_curve_name(int nid)
- * }
- */
- public static MemorySegment EC_KEY_new_by_curve_name(int nid) {
- var mh$ = EC_KEY_new_by_curve_name$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EC_KEY_new_by_curve_name", nid);
- }
- return (MemorySegment) mh$.invokeExact(nid);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle EC_KEY_free$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("EC_KEY_free"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void EC_KEY_free(EC_KEY *key)
- * }
- */
- public static void EC_KEY_free(MemorySegment key) {
- var mh$ = EC_KEY_free$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("EC_KEY_free", key);
- }
- mh$.invokeExact(key);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle DH_new$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("DH_new"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * DH *DH_new(void)
- * }
- */
- public static MemorySegment DH_new() {
- var mh$ = DH_new$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("DH_new");
- }
- return (MemorySegment) mh$.invokeExact();
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle DH_free$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("DH_free"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void DH_free(DH *dh)
- * }
- */
- public static void DH_free(MemorySegment dh) {
- var mh$ = DH_free$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("DH_free", dh);
- }
- mh$.invokeExact(dh);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle DH_set0_pqg$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("DH_set0_pqg"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
- * }
- */
- public static int DH_set0_pqg(MemorySegment dh, MemorySegment p, MemorySegment q, MemorySegment g) {
- var mh$ = DH_set0_pqg$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("DH_set0_pqg", dh, p, q, g);
- }
- return (int) mh$.invokeExact(dh, p, q, g);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_STORE_set_flags$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_LONG
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_STORE_set_flags"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags)
- * }
- */
- public static int X509_STORE_set_flags(MemorySegment ctx, long flags) {
- var mh$ = X509_STORE_set_flags$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_STORE_set_flags", ctx, flags);
- }
- return (int) mh$.invokeExact(ctx, flags);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_STORE_CTX_get0_untrusted$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_STORE_CTX_get0_untrusted"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * struct stack_st_X509 *X509_STORE_CTX_get0_untrusted(const X509_STORE_CTX *ctx)
- * }
- */
- public static MemorySegment X509_STORE_CTX_get0_untrusted(MemorySegment ctx) {
- var mh$ = X509_STORE_CTX_get0_untrusted$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_STORE_CTX_get0_untrusted", ctx);
- }
- return (MemorySegment) mh$.invokeExact(ctx);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_STORE_add_lookup$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_STORE_add_lookup"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m)
- * }
- */
- public static MemorySegment X509_STORE_add_lookup(MemorySegment v, MemorySegment m) {
- var mh$ = X509_STORE_add_lookup$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_STORE_add_lookup", v, m);
- }
- return (MemorySegment) mh$.invokeExact(v, m);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_LOOKUP_hash_dir$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_LOOKUP_hash_dir"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void)
- * }
- */
- public static MemorySegment X509_LOOKUP_hash_dir() {
- var mh$ = X509_LOOKUP_hash_dir$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_LOOKUP_hash_dir");
- }
- return (MemorySegment) mh$.invokeExact();
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_LOOKUP_file$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_LOOKUP_file"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * X509_LOOKUP_METHOD *X509_LOOKUP_file(void)
- * }
- */
- public static MemorySegment X509_LOOKUP_file() {
- var mh$ = X509_LOOKUP_file$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_LOOKUP_file");
- }
- return (MemorySegment) mh$.invokeExact();
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_LOOKUP_ctrl$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_LONG,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_LOOKUP_ctrl"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret)
- * }
- */
- public static int X509_LOOKUP_ctrl(MemorySegment ctx, int cmd, MemorySegment argc, long argl, MemorySegment ret) {
- var mh$ = X509_LOOKUP_ctrl$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_LOOKUP_ctrl", ctx, cmd, argc, argl, ret);
- }
- return (int) mh$.invokeExact(ctx, cmd, argc, argl, ret);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_STORE_CTX_get_ex_data$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_STORE_CTX_get_ex_data"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void *X509_STORE_CTX_get_ex_data(const X509_STORE_CTX *ctx, int idx)
- * }
- */
- public static MemorySegment X509_STORE_CTX_get_ex_data(MemorySegment ctx, int idx) {
- var mh$ = X509_STORE_CTX_get_ex_data$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_STORE_CTX_get_ex_data", ctx, idx);
- }
- return (MemorySegment) mh$.invokeExact(ctx, idx);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_STORE_CTX_get_error$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_STORE_CTX_get_error"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int X509_STORE_CTX_get_error(const X509_STORE_CTX *ctx)
- * }
- */
- public static int X509_STORE_CTX_get_error(MemorySegment ctx) {
- var mh$ = X509_STORE_CTX_get_error$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_STORE_CTX_get_error", ctx);
- }
- return (int) mh$.invokeExact(ctx);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_STORE_CTX_set_error$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_STORE_CTX_set_error"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s)
- * }
- */
- public static void X509_STORE_CTX_set_error(MemorySegment ctx, int s) {
- var mh$ = X509_STORE_CTX_set_error$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_STORE_CTX_set_error", ctx, s);
- }
- mh$.invokeExact(ctx, s);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_STORE_CTX_get_error_depth$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_STORE_CTX_get_error_depth"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int X509_STORE_CTX_get_error_depth(const X509_STORE_CTX *ctx)
- * }
- */
- public static int X509_STORE_CTX_get_error_depth(MemorySegment ctx) {
- var mh$ = X509_STORE_CTX_get_error_depth$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_STORE_CTX_get_error_depth", ctx);
- }
- return (int) mh$.invokeExact(ctx);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_STORE_CTX_get_current_cert$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_STORE_CTX_get_current_cert"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * X509 *X509_STORE_CTX_get_current_cert(const X509_STORE_CTX *ctx)
- * }
- */
- public static MemorySegment X509_STORE_CTX_get_current_cert(MemorySegment ctx) {
- var mh$ = X509_STORE_CTX_get_current_cert$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_STORE_CTX_get_current_cert", ctx);
- }
- return (MemorySegment) mh$.invokeExact(ctx);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_STORE_CTX_get0_current_issuer$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_STORE_CTX_get0_current_issuer"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * X509 *X509_STORE_CTX_get0_current_issuer(const X509_STORE_CTX *ctx)
- * }
- */
- public static MemorySegment X509_STORE_CTX_get0_current_issuer(MemorySegment ctx) {
- var mh$ = X509_STORE_CTX_get0_current_issuer$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_STORE_CTX_get0_current_issuer", ctx);
- }
- return (MemorySegment) mh$.invokeExact(ctx);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle d2i_X509_bio$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("d2i_X509_bio"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * X509 *d2i_X509_bio(BIO *bp, X509 **x509)
- * }
- */
- public static MemorySegment d2i_X509_bio(MemorySegment bp, MemorySegment x509) {
- var mh$ = d2i_X509_bio$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("d2i_X509_bio", bp, x509);
- }
- return (MemorySegment) mh$.invokeExact(bp, x509);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_free$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_free"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * extern void X509_free(X509 *a)
- * }
- */
- public static void X509_free(MemorySegment a) {
- var mh$ = X509_free$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_free", a);
- }
- mh$.invokeExact(a);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle d2i_X509$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_LONG
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("d2i_X509"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * extern X509 *d2i_X509(X509 **a, const unsigned char **in, long len)
- * }
- */
- public static MemorySegment d2i_X509(MemorySegment a, MemorySegment in, long len) {
- var mh$ = d2i_X509$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("d2i_X509", a, in, len);
- }
- return (MemorySegment) mh$.invokeExact(a, in, len);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle i2d_X509$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("i2d_X509"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * extern int i2d_X509(const X509 *a, unsigned char **out)
- * }
- */
- public static int i2d_X509(MemorySegment a, MemorySegment out) {
- var mh$ = i2d_X509$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("i2d_X509", a, out);
- }
- return (int) mh$.invokeExact(a, out);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_get_ext_by_NID$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_INT,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_get_ext_by_NID"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos)
- * }
- */
- public static int X509_get_ext_by_NID(MemorySegment x, int nid, int lastpos) {
- var mh$ = X509_get_ext_by_NID$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_get_ext_by_NID", x, nid, lastpos);
- }
- return (int) mh$.invokeExact(x, nid, lastpos);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_get_ext$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_INT
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_get_ext"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * X509_EXTENSION *X509_get_ext(const X509 *x, int loc)
- * }
- */
- public static MemorySegment X509_get_ext(MemorySegment x, int loc) {
- var mh$ = X509_get_ext$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_get_ext", x, loc);
- }
- return (MemorySegment) mh$.invokeExact(x, loc);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle X509_EXTENSION_get_data$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("X509_EXTENSION_get_data"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne)
- * }
- */
- public static MemorySegment X509_EXTENSION_get_data(MemorySegment ne) {
- var mh$ = X509_EXTENSION_get_data$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("X509_EXTENSION_get_data", ne);
- }
- return (MemorySegment) mh$.invokeExact(ne);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle PEM_ASN1_read_bio$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("PEM_ASN1_read_bio"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, pem_password_cb *cb, void *u)
- * }
- */
- public static MemorySegment PEM_ASN1_read_bio(MemorySegment d2i, MemorySegment name, MemorySegment bp, MemorySegment x, MemorySegment cb, MemorySegment u) {
- var mh$ = PEM_ASN1_read_bio$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("PEM_ASN1_read_bio", d2i, name, bp, x, cb, u);
- }
- return (MemorySegment) mh$.invokeExact(d2i, name, bp, x, cb, u);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle PEM_read_bio_X509_AUX$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("PEM_read_bio_X509_AUX"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * extern X509 *PEM_read_bio_X509_AUX(BIO *out, X509 **x, pem_password_cb *cb, void *u)
- * }
- */
- public static MemorySegment PEM_read_bio_X509_AUX(MemorySegment out, MemorySegment x, MemorySegment cb, MemorySegment u) {
- var mh$ = PEM_read_bio_X509_AUX$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("PEM_read_bio_X509_AUX", out, x, cb, u);
- }
- return (MemorySegment) mh$.invokeExact(out, x, cb, u);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle PEM_read_bio_ECPKParameters$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("PEM_read_bio_ECPKParameters"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * EC_GROUP *PEM_read_bio_ECPKParameters(BIO *out, EC_GROUP **x, pem_password_cb *cb, void *u)
- * }
- */
- public static MemorySegment PEM_read_bio_ECPKParameters(MemorySegment out, MemorySegment x, MemorySegment cb, MemorySegment u) {
- var mh$ = PEM_read_bio_ECPKParameters$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("PEM_read_bio_ECPKParameters", out, x, cb, u);
- }
- return (MemorySegment) mh$.invokeExact(out, x, cb, u);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle PEM_read_bio_DHparams$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("PEM_read_bio_DHparams"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * DH *PEM_read_bio_DHparams(BIO *out, DH **x, pem_password_cb *cb, void *u)
- * }
- */
- public static MemorySegment PEM_read_bio_DHparams(MemorySegment out, MemorySegment x, MemorySegment cb, MemorySegment u) {
- var mh$ = PEM_read_bio_DHparams$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("PEM_read_bio_DHparams", out, x, cb, u);
- }
- return (MemorySegment) mh$.invokeExact(out, x, cb, u);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle PEM_read_bio_PrivateKey$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("PEM_read_bio_PrivateKey"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * extern EVP_PKEY *PEM_read_bio_PrivateKey(BIO *out, EVP_PKEY **x, pem_password_cb *cb, void *u)
- * }
- */
- public static MemorySegment PEM_read_bio_PrivateKey(MemorySegment out, MemorySegment x, MemorySegment cb, MemorySegment u) {
- var mh$ = PEM_read_bio_PrivateKey$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("PEM_read_bio_PrivateKey", out, x, cb, u);
- }
- return (MemorySegment) mh$.invokeExact(out, x, cb, u);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle PEM_read_bio_Parameters$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("PEM_read_bio_Parameters"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x)
- * }
- */
- public static MemorySegment PEM_read_bio_Parameters(MemorySegment bp, MemorySegment x) {
- var mh$ = PEM_read_bio_Parameters$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("PEM_read_bio_Parameters", bp, x);
- }
- return (MemorySegment) mh$.invokeExact(bp, x);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_get_options$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_get_options"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * uint64_t SSL_CTX_get_options(const SSL_CTX *ctx)
- * }
- */
- public static long SSL_CTX_get_options(MemorySegment ctx) {
- var mh$ = SSL_CTX_get_options$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_get_options", ctx);
- }
- return (long) mh$.invokeExact(ctx);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_get_options$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_get_options"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * uint64_t SSL_get_options(const SSL *s)
- * }
- */
- public static long SSL_get_options(MemorySegment s) {
- var mh$ = SSL_get_options$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_get_options", s);
- }
- return (long) mh$.invokeExact(s);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_clear_options$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER,
- openssl_h.C_LONG
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_clear_options"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * uint64_t SSL_CTX_clear_options(SSL_CTX *ctx, uint64_t op)
- * }
- */
- public static long SSL_CTX_clear_options(MemorySegment ctx, long op) {
- var mh$ = SSL_CTX_clear_options$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_clear_options", ctx, op);
- }
- return (long) mh$.invokeExact(ctx, op);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set_options$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER,
- openssl_h.C_LONG
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_set_options"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * uint64_t SSL_CTX_set_options(SSL_CTX *ctx, uint64_t op)
- * }
- */
- public static long SSL_CTX_set_options(MemorySegment ctx, long op) {
- var mh$ = SSL_CTX_set_options$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_set_options", ctx, op);
- }
- return (long) mh$.invokeExact(ctx, op);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_set_options$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER,
- openssl_h.C_LONG
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_set_options"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * uint64_t SSL_set_options(SSL *s, uint64_t op)
- * }
- */
- public static long SSL_set_options(MemorySegment s, long op) {
- var mh$ = SSL_set_options$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_set_options", s, op);
- }
- return (long) mh$.invokeExact(s, op);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set_alpn_select_cb$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_set_alpn_select_cb"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx, SSL_CTX_alpn_select_cb_func cb, void *arg)
- * }
- */
- public static void SSL_CTX_set_alpn_select_cb(MemorySegment ctx, MemorySegment cb, MemorySegment arg) {
- var mh$ = SSL_CTX_set_alpn_select_cb$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_set_alpn_select_cb", ctx, cb, arg);
- }
- mh$.invokeExact(ctx, cb, arg);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_get0_alpn_selected$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_get0_alpn_selected"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data, unsigned int *len)
- * }
- */
- public static void SSL_get0_alpn_selected(MemorySegment ssl, MemorySegment data, MemorySegment len) {
- var mh$ = SSL_get0_alpn_selected$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_get0_alpn_selected", ssl, data, len);
- }
- mh$.invokeExact(ssl, data, len);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_in_init$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_in_init"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_in_init(const SSL *s)
- * }
- */
- public static int SSL_in_init(MemorySegment s) {
- var mh$ = SSL_in_init$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_in_init", s);
- }
- return (int) mh$.invokeExact(s);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set0_tmp_dh_pkey$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_set0_tmp_dh_pkey"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_CTX_set0_tmp_dh_pkey(SSL_CTX *ctx, EVP_PKEY *dhpkey)
- * }
- */
- public static int SSL_CTX_set0_tmp_dh_pkey(MemorySegment ctx, MemorySegment dhpkey) {
- var mh$ = SSL_CTX_set0_tmp_dh_pkey$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_set0_tmp_dh_pkey", ctx, dhpkey);
- }
- return (int) mh$.invokeExact(ctx, dhpkey);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set_cipher_list$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_set_cipher_list"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_CTX_set_cipher_list(SSL_CTX *, const char *str)
- * }
- */
- public static int SSL_CTX_set_cipher_list(MemorySegment x0, MemorySegment str) {
- var mh$ = SSL_CTX_set_cipher_list$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_set_cipher_list", x0, str);
- }
- return (int) mh$.invokeExact(x0, str);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_new$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_new"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
- * }
- */
- public static MemorySegment SSL_CTX_new(MemorySegment meth) {
- var mh$ = SSL_CTX_new$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_new", meth);
- }
- return (MemorySegment) mh$.invokeExact(meth);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_free$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_free"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void SSL_CTX_free(SSL_CTX *)
- * }
- */
- public static void SSL_CTX_free(MemorySegment x0) {
- var mh$ = SSL_CTX_free$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_free", x0);
- }
- mh$.invokeExact(x0);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set_timeout$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER,
- openssl_h.C_LONG
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_set_timeout"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * long SSL_CTX_set_timeout(SSL_CTX *ctx, long t)
- * }
- */
- public static long SSL_CTX_set_timeout(MemorySegment ctx, long t) {
- var mh$ = SSL_CTX_set_timeout$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_set_timeout", ctx, t);
- }
- return (long) mh$.invokeExact(ctx, t);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_get_timeout$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_get_timeout"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * long SSL_CTX_get_timeout(const SSL_CTX *ctx)
- * }
- */
- public static long SSL_CTX_get_timeout(MemorySegment ctx) {
- var mh$ = SSL_CTX_get_timeout$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_get_timeout", ctx);
- }
- return (long) mh$.invokeExact(ctx);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_get_cert_store$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_get_cert_store"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *)
- * }
- */
- public static MemorySegment SSL_CTX_get_cert_store(MemorySegment x0) {
- var mh$ = SSL_CTX_get_cert_store$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_get_cert_store", x0);
- }
- return (MemorySegment) mh$.invokeExact(x0);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_get_current_cipher$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_get_current_cipher"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * const SSL_CIPHER *SSL_get_current_cipher(const SSL *s)
- * }
- */
- public static MemorySegment SSL_get_current_cipher(MemorySegment s) {
- var mh$ = SSL_get_current_cipher$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_get_current_cipher", s);
- }
- return (MemorySegment) mh$.invokeExact(s);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CIPHER_get_name$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CIPHER_get_name"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * const char *SSL_CIPHER_get_name(const SSL_CIPHER *c)
- * }
- */
- public static MemorySegment SSL_CIPHER_get_name(MemorySegment c) {
- var mh$ = SSL_CIPHER_get_name$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CIPHER_get_name", c);
- }
- return (MemorySegment) mh$.invokeExact(c);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CIPHER_get_kx_nid$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CIPHER_get_kx_nid"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c)
- * }
- */
- public static int SSL_CIPHER_get_kx_nid(MemorySegment c) {
- var mh$ = SSL_CIPHER_get_kx_nid$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CIPHER_get_kx_nid", c);
- }
- return (int) mh$.invokeExact(c);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CIPHER_get_auth_nid$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CIPHER_get_auth_nid"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c)
- * }
- */
- public static int SSL_CIPHER_get_auth_nid(MemorySegment c) {
- var mh$ = SSL_CIPHER_get_auth_nid$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CIPHER_get_auth_nid", c);
- }
- return (int) mh$.invokeExact(c);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_pending$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_pending"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_pending(const SSL *s)
- * }
- */
- public static int SSL_pending(MemorySegment s) {
- var mh$ = SSL_pending$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_pending", s);
- }
- return (int) mh$.invokeExact(s);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_set_bio$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_set_bio"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio)
- * }
- */
- public static void SSL_set_bio(MemorySegment s, MemorySegment rbio, MemorySegment wbio) {
- var mh$ = SSL_set_bio$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_set_bio", s, rbio, wbio);
- }
- mh$.invokeExact(s, rbio, wbio);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_set_cipher_list$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_set_cipher_list"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_set_cipher_list(SSL *s, const char *str)
- * }
- */
- public static int SSL_set_cipher_list(MemorySegment s, MemorySegment str) {
- var mh$ = SSL_set_cipher_list$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_set_cipher_list", s, str);
- }
- return (int) mh$.invokeExact(s, str);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set_ciphersuites$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_set_ciphersuites"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str)
- * }
- */
- public static int SSL_CTX_set_ciphersuites(MemorySegment ctx, MemorySegment str) {
- var mh$ = SSL_CTX_set_ciphersuites$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_set_ciphersuites", ctx, str);
- }
- return (int) mh$.invokeExact(ctx, str);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_set_verify$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_set_verify"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void SSL_set_verify(SSL *s, int mode, SSL_verify_cb callback)
- * }
- */
- public static void SSL_set_verify(MemorySegment s, int mode, MemorySegment callback) {
- var mh$ = SSL_set_verify$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_set_verify", s, mode, callback);
- }
- mh$.invokeExact(s, mode, callback);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_use_certificate_chain_file$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_use_certificate_chain_file"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
- * }
- */
- public static int SSL_CTX_use_certificate_chain_file(MemorySegment ctx, MemorySegment file) {
- var mh$ = SSL_CTX_use_certificate_chain_file$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_use_certificate_chain_file", ctx, file);
- }
- return (int) mh$.invokeExact(ctx, file);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_load_client_CA_file$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_load_client_CA_file"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * struct stack_st_X509_NAME *SSL_load_client_CA_file(const char *file)
- * }
- */
- public static MemorySegment SSL_load_client_CA_file(MemorySegment file) {
- var mh$ = SSL_load_client_CA_file$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_load_client_CA_file", file);
- }
- return (MemorySegment) mh$.invokeExact(file);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_add_file_cert_subjects_to_stack$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_add_file_cert_subjects_to_stack"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_add_file_cert_subjects_to_stack(struct stack_st_X509_NAME *stackCAs, const char *file)
- * }
- */
- public static int SSL_add_file_cert_subjects_to_stack(MemorySegment stackCAs, MemorySegment file) {
- var mh$ = SSL_add_file_cert_subjects_to_stack$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_add_file_cert_subjects_to_stack", stackCAs, file);
- }
- return (int) mh$.invokeExact(stackCAs, file);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_SESSION_get_time$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_LONG,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_SESSION_get_time"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * long SSL_SESSION_get_time(const SSL_SESSION *s)
- * }
- */
- public static long SSL_SESSION_get_time(MemorySegment s) {
- var mh$ = SSL_SESSION_get_time$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_SESSION_get_time", s);
- }
- return (long) mh$.invokeExact(s);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_SESSION_get_id$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_SESSION_get_id"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len)
- * }
- */
- public static MemorySegment SSL_SESSION_get_id(MemorySegment s, MemorySegment len) {
- var mh$ = SSL_SESSION_get_id$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_SESSION_get_id", s, len);
- }
- return (MemorySegment) mh$.invokeExact(s, len);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_get1_peer_certificate$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_get1_peer_certificate"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * X509 *SSL_get1_peer_certificate(const SSL *s)
- * }
- */
- public static MemorySegment SSL_get1_peer_certificate(MemorySegment s) {
- var mh$ = SSL_get1_peer_certificate$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_get1_peer_certificate", s);
- }
- return (MemorySegment) mh$.invokeExact(s);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_get_peer_cert_chain$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_get_peer_cert_chain"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * struct stack_st_X509 *SSL_get_peer_cert_chain(const SSL *s)
- * }
- */
- public static MemorySegment SSL_get_peer_cert_chain(MemorySegment s) {
- var mh$ = SSL_get_peer_cert_chain$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_get_peer_cert_chain", s);
- }
- return (MemorySegment) mh$.invokeExact(s);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set_verify$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_set_verify"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, SSL_verify_cb callback)
- * }
- */
- public static void SSL_CTX_set_verify(MemorySegment ctx, int mode, MemorySegment callback) {
- var mh$ = SSL_CTX_set_verify$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_set_verify", ctx, mode, callback);
- }
- mh$.invokeExact(ctx, mode, callback);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set_cert_verify_callback$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_set_cert_verify_callback"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *, void *), void *arg)
- * }
- */
- public static void SSL_CTX_set_cert_verify_callback(MemorySegment ctx, MemorySegment cb, MemorySegment arg) {
- var mh$ = SSL_CTX_set_cert_verify_callback$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_set_cert_verify_callback", ctx, cb, arg);
- }
- mh$.invokeExact(ctx, cb, arg);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_use_PrivateKey$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_use_PrivateKey"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey)
- * }
- */
- public static int SSL_CTX_use_PrivateKey(MemorySegment ctx, MemorySegment pkey) {
- var mh$ = SSL_CTX_use_PrivateKey$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_use_PrivateKey", ctx, pkey);
- }
- return (int) mh$.invokeExact(ctx, pkey);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_use_certificate$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_use_certificate"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x)
- * }
- */
- public static int SSL_CTX_use_certificate(MemorySegment ctx, MemorySegment x) {
- var mh$ = SSL_CTX_use_certificate$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_use_certificate", ctx, x);
- }
- return (int) mh$.invokeExact(ctx, x);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set_default_passwd_cb$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid(
- openssl_h.C_POINTER,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_set_default_passwd_cb"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb)
- * }
- */
- public static void SSL_CTX_set_default_passwd_cb(MemorySegment ctx, MemorySegment cb) {
- var mh$ = SSL_CTX_set_default_passwd_cb$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_set_default_passwd_cb", ctx, cb);
- }
- mh$.invokeExact(ctx, cb);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_check_private_key$MH() {
- class Holder {
- static final FunctionDescriptor DESC = FunctionDescriptor.of(
- openssl_h.C_INT,
- openssl_h.C_POINTER
- );
-
- static final MethodHandle MH = Linker.nativeLinker().downcallHandle(
- openssl_h.findOrThrow("SSL_CTX_check_private_key"),
- DESC);
- }
- return Holder.MH;
- }
-
- /**
- * {@snippet lang=c :
- * int SSL_CTX_check_private_key(const SSL_CTX *ctx)
- * }
- */
- public static int SSL_CTX_check_private_key(MemorySegment ctx) {
- var mh$ = SSL_CTX_check_private_key$MH();
- try {
- if (TRACE_DOWNCALLS) {
- traceDowncall("SSL_CTX_check_private_key", ctx);
- }
- return (int) mh$.invokeExact(ctx);
- } catch (Throwable ex$) {
- throw new AssertionError("should not reach here", ex$);
- }
- }
-
- private static MethodHandle SSL_CTX_set_session_id_context$MH() {
... 25483 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org