├── .gitignore
├── CMakeLists.txt
├── HOWTO-RELEASE.txt
├── KEYS
├── LICENSE
├── NOTICE
├── README.txt
├── build.properties.default
├── build.xml
├── java
├── org
│ └── apache
│ │ └── tomcat
│ │ └── jni
│ │ ├── Buffer.java
│ │ ├── CertificateVerifier.java
│ │ ├── FileInfo.java
│ │ ├── Library.java
│ │ ├── LibraryNotFoundError.java
│ │ ├── Pool.java
│ │ ├── SSL.java
│ │ ├── SSLConf.java
│ │ ├── SSLContext.java
│ │ └── Sockaddr.java
└── overview.html
├── jnirelease.sh
├── native
├── BUILDING
├── LICENSE.bin.win
├── Makefile.in
├── NMAKEmakefile
├── NMAKEmakefile.inc
├── NOTICE.bin.win
├── build.conf
├── build
│ ├── PrintPath
│ ├── api.pl
│ ├── buildcheck.sh
│ ├── get-version.sh
│ ├── lineends.pl
│ ├── mkdir.sh
│ ├── rpm
│ │ └── tcnative.spec.in
│ └── tcnative.m4
├── buildconf
├── config.layout
├── configure.ac
├── download_deps.sh
├── include
│ ├── ssl_private.h
│ ├── tcn.h
│ ├── tcn_api.h
│ └── tcn_version.h
├── libtcnative.dsp
├── libtcnative.dsw
├── os
│ └── win32
│ │ ├── apache.ico
│ │ ├── libtcnative.rc
│ │ └── system.c
├── src
│ ├── bb.c
│ ├── error.c
│ ├── jnilib.c
│ ├── pool.c
│ ├── ssl.c
│ ├── sslconf.c
│ ├── sslcontext.c
│ └── sslutils.c
├── srclib
│ ├── BUILDING
│ ├── VERSIONS
│ ├── apr
│ │ └── NMAKEmakefile
│ └── openssl
│ │ └── .gitkeep
└── tcnative.dsp
├── test
└── org
│ └── apache
│ └── tomcat
│ └── jni
│ └── TesterSSL.java
└── xdocs
├── build.xml
├── images
├── add.gif
├── asf-logo.svg
├── code.gif
├── design.gif
├── docs-stylesheet.css
├── docs.gif
├── fix.gif
├── printer.gif
├── style.css
├── tomcat.gif
├── tomcat.png
├── update.gif
└── void.gif
├── index.xml
├── miscellaneous
├── changelog.xml
├── project.xml
└── tls-renegotiation.xml
├── news
├── 2022.xml
├── 2023.xml
├── 2024.xml
├── 2025.xml
└── project.xml
├── project.xml
└── style.xsl
/.gitignore:
--------------------------------------------------------------------------------
1 | .classpath
2 | .project
3 |
4 | /build
5 | /dist
6 |
7 | /.settings/
8 | /native/.libs/
9 | /native/.make.dirs
10 | /native/Makefile
11 | /native/build-outputs.mk
12 | /native/build/apr_common.m4
13 | /native/build/config.guess
14 | /native/build/config.sub
15 | /native/build/find_apr.m4
16 | /native/build/install.sh
17 | /native/build/install-sh
18 | /native/build/ltmain.sh
19 | /native/build/rules.mk
20 | /native/aclocal.m4
21 | /native/config.log
22 | /native/config.nice
23 | /native/config.status
24 | /native/configure
25 | /native/configure~
26 | /native/libtcnative-1.la
27 | /native/libtcnative-2.la
28 | /native/libtool
29 | /native/tcnative.pc
30 | /native/tcnative.spec
31 |
32 | /native/srclib/apr/*
33 | !/native/srclib/apr/NMAKEmakefile
34 |
35 | /native/srclib/openssl/*
36 | !/native/srclib/openssl/.gitkeep
37 |
38 | /native/*RELEASE
39 | /tomcat-native-*
40 | /tomcat-native-*/
41 |
42 | **/*.lo
43 | **/*.o
44 |
45 | build.properties
46 |
--------------------------------------------------------------------------------
/HOWTO-RELEASE.txt:
--------------------------------------------------------------------------------
1 | ================================================================================
2 | Licensed to the Apache Software Foundation (ASF) under one or more
3 | contributor license agreements. See the NOTICE file distributed with
4 | this work for additional information regarding copyright ownership.
5 | The ASF licenses this file to You under the Apache License, Version 2.0
6 | (the "License"); you may not use this file except in compliance with
7 | the License. You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | ================================================================================
17 |
18 | How to do a Tomcat Native release
19 | =================================
20 |
21 | Requirements
22 | ------------
23 |
24 | Java 11
25 | Apache Ant 1.9 or later
26 | Apache APR 1.7.0 or later source
27 |
28 |
29 | Preparation
30 | -----------
31 |
32 | Review the open issues in Bugzilla.
33 | Review open PRs in GitHub.
34 |
35 | If you haven't already, add your public PGP key to KEYS.
36 |
37 | Ensure dates and/or version numbers are up to date:
38 | - build.properties.default
39 | - native/build/rpm/tcnative.spec.in
40 | - native/include/tcn_version.h
41 | - native/os/win32/libtcnative.rc x3
42 | - xdocs/miscellaneous/changelog.xml
43 |
44 | Run the release script to check the Java code is aligned with the current 11.0.x
45 | source.
46 | ./jnirelease.sh --ver=main --with-apr=/path/to/apr/source
47 |
48 | Switch back to the main branch
49 | git checkout main
50 |
51 | Tagging
52 | -------
53 |
54 | # Check clone is up to date and clean
55 | git pull
56 | git status
57 |
58 | # Edit files to remove / disable dev build flags
59 | # - build.properties.default
60 | # - tcn_version.h
61 |
62 | # Confirm the previous edits
63 | git diff
64 |
65 | # Tag (modify version as appropriate)
66 | git commit -a -m "Tag 2.0.0"
67 | git tag 2.0.0
68 | git push origin 2.0.0
69 |
70 | # Reset main
71 | git reset --hard HEAD~1
72 |
73 |
74 | Create the source release
75 | -------------------------
76 |
77 | # Modify version as appropriate
78 | ./jnirelease.sh --ver=2.0.0 --with-apr=/path/to/apr/source
79 |
80 | # Switch back to the main branch
81 | git checkout main
82 |
83 |
84 | Create the binary release for Windows
85 | -------------------------------------
86 |
87 | See native/building
88 |
--------------------------------------------------------------------------------
/KEYS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/KEYS
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Apache Tomcat Native Library
2 | Copyright 2002-2025 The Apache Software Foundation
3 |
4 | This product includes software developed at
5 | The Apache Software Foundation (http://www.apache.org/).
6 |
7 | This software contains code derived from netty-native
8 | developed by the Netty project
9 | (http://netty.io, https://github.com/netty/netty-tcnative/)
10 | and from finagle-native developed at Twitter
11 | (https://github.com/twitter/finagle).
12 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache Tomcat Native Library
3 |
4 |
5 | What is it?
6 | -----------
7 |
8 | The Apache Tomcat Native Library is an optional component for use with
9 | Apache Tomcat that allows Tomcat to use OpenSSL as a replacement for JSSE
10 | to support TLS connections.
11 |
12 |
13 | Licensing
14 | ---------
15 |
16 | Please see the file called LICENSE.
17 |
18 | The Latest Version
19 | ------------------
20 |
21 | Details of the latest version can be found on the Apache Tomcat
22 | project page under https://tomcat.apache.org/.
23 |
24 | Documentation
25 | -------------
26 |
27 | The documentation available as of the date of this release is
28 | included in HTML format in the docs directory.
29 | The most up-to-date documentation can be found at
30 | https://tomcat.apache.org/native-doc/
31 |
32 |
33 | Building
34 | --------
35 |
36 | To build the Java API. Note that Java 11 is required to build the Java API.
37 | > ant
38 |
39 | To build the native part see native/BUILDING.
40 |
41 |
42 | Cryptographic Software Notice
43 | -----------------------------
44 |
45 | This distribution may include software that has been designed for use
46 | with cryptographic software. The country in which you currently reside
47 | may have restrictions on the import, possession, use, and/or re-export
48 | to another country, of encryption software. BEFORE using any encryption
49 | software, please check your country's laws, regulations and policies
50 | concerning the import, possession, or use, and re-export of encryption
51 | software, to see if this is permitted. See
52 | for more information.
53 |
54 | The U.S. Government Department of Commerce, Bureau of Industry and
55 | Security (BIS), has classified this software as Export Commodity
56 | Control Number (ECCN) 5D002.C.1, which includes information security
57 | software using or performing cryptographic functions with asymmetric
58 | algorithms. The form and manner of this Apache Software Foundation
59 | distribution makes it eligible for export under the License Exception
60 | ENC Technology Software Unrestricted (TSU) exception (see the BIS
61 | Export Administration Regulations, Section 740.13) for both object
62 | code and source code.
63 |
64 | Apache Tomcat Native uses cryptographic software for configuring and
65 | listening to connections over SSL encrypted network sockets by
66 | performing calls to a general-purpose encryption library, such as
67 | OpenSSL or the operating system's platform-specific SSL facilities.
68 |
--------------------------------------------------------------------------------
/build.properties.default:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | # ----- Version Control Flags -----
19 | version.major=2
20 | version.minor=0
21 | version.build=9
22 | version.patch=0
23 | version.suffix=-dev
24 |
25 | # ----- Default Base Path for Dependent Packages -----
26 | # Please note this path must be absolute, not relative,
27 | # as it is referenced with different working directory
28 | # contexts by the various build scripts.
29 | base.path=/usr/share/java
30 | #base.path=C:/path/to/the/repository
31 | #base.path=/usr/local
32 |
33 | # ----- Build tools -----
34 | ant.version.required=1.10.2
35 |
36 | # ----- Build control flags -----
37 | compile.debug=true
38 | # Do not pass -deprecation (-Xlint:deprecation) flag to javac
39 | compile.deprecation=false
40 |
41 | base-maven.loc=https://repo.maven.apache.org/maven2
42 |
43 | # ----- JUnit Unit Test Suite, version 4.11 or later -----
44 | junit.version=4.11
45 | junit.home=${base.path}/junit-${junit.version}
46 | junit.jar=${junit.home}/junit-${junit.version}.jar
47 | junit.loc=${base-maven.loc}/junit/junit/${junit.version}/junit-${junit.version}.jar
48 |
49 | # ----- Hamcrest Library, used by JUnit, version 1.3 or later ----
50 | hamcrest.version=1.3
51 | hamcrest.home=${base.path}/hamcrest-${hamcrest.version}
52 | hamcrest.jar=${hamcrest.home}/hamcrest-core-${hamcrest.version}.jar
53 | hamcrest.loc=${base-maven.loc}/org/hamcrest/hamcrest-core/${hamcrest.version}/hamcrest-core-${hamcrest.version}.jar
54 |
--------------------------------------------------------------------------------
/java/org/apache/tomcat/jni/Buffer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.tomcat.jni;
18 |
19 | import java.nio.ByteBuffer;
20 |
21 | /**
22 | * Provides utilities related to the use of directly allocated {@link ByteBuffer} instances with native code.
23 | */
24 | public class Buffer {
25 |
26 | /**
27 | * Returns the memory address of the ByteBuffer.
28 | *
29 | * @param buf Previously allocated ByteBuffer.
30 | *
31 | * @return the memory address
32 | */
33 | public static native long address(ByteBuffer buf);
34 | }
35 |
--------------------------------------------------------------------------------
/java/org/apache/tomcat/jni/CertificateVerifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.tomcat.jni;
18 |
19 | /**
20 | * Is called during handshake and hooked into openssl via {@code SSL_CTX_set_cert_verify_callback}.
21 | */
22 | public interface CertificateVerifier {
23 |
24 | /**
25 | * Returns {@code true} if the passed in certificate chain could be verified and so the handshake should be
26 | * successful, {@code false} otherwise.
27 | *
28 | * @param ssl the SSL instance
29 | * @param x509 the {@code X509} certificate chain
30 | * @param authAlgorithm the auth algorithm
31 | *
32 | * @return verified {@code true} if verified successful, {@code false} otherwise
33 | */
34 | boolean verify(long ssl, byte[][] x509, String authAlgorithm);
35 | }
36 |
--------------------------------------------------------------------------------
/java/org/apache/tomcat/jni/FileInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.tomcat.jni;
18 |
19 | /**
20 | * Tomcat Native 1.2.33 and earlier won't initialise unless this class is present. This dummy class ensures
21 | * initialisation gets as far as being able to check the version of the Tomcat Native library and reporting a version
22 | * error if 1.2.33 or earlier is present.
23 | */
24 | public class FileInfo {
25 |
26 | private FileInfo() {
27 | // Hide default constructor
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/java/org/apache/tomcat/jni/Library.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.tomcat.jni;
18 |
19 | import java.io.File;
20 |
21 | public final class Library {
22 |
23 | /* Default library names - use 2.x in preference to 1.x if both are available */
24 | private static final String[] NAMES = { "tcnative-2", "libtcnative-2", "tcnative-1", "libtcnative-1" };
25 | /* System property used to define CATALINA_HOME */
26 | private static final String CATALINA_HOME_PROP = "catalina.home";
27 | /*
28 | * A handle to the unique Library singleton instance.
29 | */
30 | private static Library _instance = null;
31 |
32 | private Library() throws Exception {
33 | boolean loaded = false;
34 | StringBuilder err = new StringBuilder();
35 | File binLib = new File(System.getProperty(CATALINA_HOME_PROP), "bin");
36 | for (int i = 0; i < NAMES.length; i++) {
37 | File library = new File(binLib, System.mapLibraryName(NAMES[i]));
38 | try {
39 | System.load(library.getAbsolutePath());
40 | loaded = true;
41 | } catch (VirtualMachineError t) {
42 | throw t;
43 | } catch (Throwable t) {
44 | if (library.exists()) {
45 | // File exists but failed to load
46 | throw t;
47 | }
48 | if (i > 0) {
49 | err.append(", ");
50 | }
51 | err.append(t.getMessage());
52 | }
53 | if (loaded) {
54 | break;
55 | }
56 | }
57 | if (!loaded) {
58 | String path = System.getProperty("java.library.path");
59 | String[] paths = path.split(File.pathSeparator);
60 | for (String value : NAMES) {
61 | try {
62 | System.loadLibrary(value);
63 | loaded = true;
64 | } catch (VirtualMachineError t) {
65 | throw t;
66 | } catch (Throwable t) {
67 | String name = System.mapLibraryName(value);
68 | for (String s : paths) {
69 | File fd = new File(s, name);
70 | if (fd.exists()) {
71 | // File exists but failed to load
72 | throw t;
73 | }
74 | }
75 | if (!err.isEmpty()) {
76 | err.append(", ");
77 | }
78 | err.append(t.getMessage());
79 | }
80 | if (loaded) {
81 | break;
82 | }
83 | }
84 | }
85 | if (!loaded) {
86 | StringBuilder names = new StringBuilder();
87 | for (String name : NAMES) {
88 | names.append(name);
89 | names.append(", ");
90 | }
91 | throw new LibraryNotFoundError(names.substring(0, names.length() - 2), err.toString());
92 | }
93 | }
94 |
95 | private Library(String libraryName) {
96 | System.loadLibrary(libraryName);
97 | }
98 |
99 | /**
100 | * Create Tomcat Native's global APR pool. This has to be the first call to TCN library.
101 | */
102 | private static native boolean initialize();
103 |
104 | /**
105 | * Destroys Tomcat Native's global APR pool. This has to be the last call to TCN library. This will destroy any APR
106 | * root pools that have not been explicitly destroyed.
107 | */
108 | public static native void terminate();
109 |
110 | /* Internal function for loading APR Features */
111 | private static native int version(int what);
112 |
113 | /* TCN_MAJOR_VERSION */
114 | public static int TCN_MAJOR_VERSION = 0;
115 | /* TCN_MINOR_VERSION */
116 | public static int TCN_MINOR_VERSION = 0;
117 | /* TCN_PATCH_VERSION */
118 | public static int TCN_PATCH_VERSION = 0;
119 | /* TCN_IS_DEV_VERSION */
120 | public static int TCN_IS_DEV_VERSION = 0;
121 | /* APR_MAJOR_VERSION */
122 | public static int APR_MAJOR_VERSION = 0;
123 | /* APR_MINOR_VERSION */
124 | public static int APR_MINOR_VERSION = 0;
125 | /* APR_PATCH_VERSION */
126 | public static int APR_PATCH_VERSION = 0;
127 | /* APR_IS_DEV_VERSION */
128 | public static int APR_IS_DEV_VERSION = 0;
129 |
130 | /* TCN_VERSION_STRING */
131 | public static native String versionString();
132 |
133 | /* APR_VERSION_STRING */
134 | public static native String aprVersionString();
135 |
136 | /**
137 | * Setup any APR internal data structures. This MUST be the first function called for any APR library.
138 | *
139 | * @param libraryName the name of the library to load
140 | *
141 | * @return {@code true} if the native code was initialized successfully otherwise {@code false}
142 | *
143 | * @throws Exception if a problem occurred during initialization
144 | */
145 | public static synchronized boolean initialize(String libraryName) throws Exception {
146 | if (_instance == null) {
147 | if (libraryName == null) {
148 | _instance = new Library();
149 | } else {
150 | _instance = new Library(libraryName);
151 | }
152 | TCN_MAJOR_VERSION = version(0x01);
153 | TCN_MINOR_VERSION = version(0x02);
154 | TCN_PATCH_VERSION = version(0x03);
155 | TCN_IS_DEV_VERSION = version(0x04);
156 | APR_MAJOR_VERSION = version(0x11);
157 | APR_MINOR_VERSION = version(0x12);
158 | APR_PATCH_VERSION = version(0x13);
159 | APR_IS_DEV_VERSION = version(0x14);
160 |
161 | if (APR_MAJOR_VERSION < 1) {
162 | throw new UnsatisfiedLinkError("Unsupported APR Version (" + aprVersionString() + ")");
163 | }
164 | }
165 | return initialize();
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/java/org/apache/tomcat/jni/LibraryNotFoundError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.tomcat.jni;
18 |
19 | import java.io.Serial;
20 |
21 | public class LibraryNotFoundError extends UnsatisfiedLinkError {
22 |
23 | @Serial
24 | private static final long serialVersionUID = 1L;
25 |
26 | private final String libraryNames;
27 |
28 | /**
29 | * @param libraryNames A list of the file names of the native libraries that failed to load
30 | * @param errors A list of the error messages received when trying to load each of the libraries
31 | */
32 | public LibraryNotFoundError(String libraryNames, String errors) {
33 | super(errors);
34 | this.libraryNames = libraryNames;
35 | }
36 |
37 | public String getLibraryNames() {
38 | return libraryNames;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/java/org/apache/tomcat/jni/Pool.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.tomcat.jni;
18 |
19 | /**
20 | * Provides access to APR memory pools which are used to manage memory allocations for natively created instances.
21 | */
22 | public class Pool {
23 |
24 | /**
25 | * Create a new pool.
26 | *
27 | * @param parent The parent pool. If this is 0, the new pool is a root pool. If it is non-zero, the new pool will
28 | * inherit all of its parent pool's attributes, except the apr_pool_t will be a sub-pool.
29 | *
30 | * @return The pool we have just created.
31 | */
32 | public static native long create(long parent);
33 |
34 | /**
35 | * Destroy the pool. This takes similar action as apr_pool_clear() and then frees all the memory. This will actually
36 | * free the memory.
37 | *
38 | * @param pool The pool to destroy
39 | */
40 | public static native void destroy(long pool);
41 | }
42 |
--------------------------------------------------------------------------------
/java/org/apache/tomcat/jni/SSLConf.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.tomcat.jni;
18 |
19 | public final class SSLConf {
20 |
21 | /**
22 | * Create a new SSL_CONF context.
23 | *
24 | * @param pool The pool to use.
25 | * @param flags The SSL_CONF flags to use. It can be any combination of the following:
26 | *
27 | *
35 | *
36 | * @return The Java representation of a pointer to the newly created SSL_CONF Context
37 | *
38 | * @throws Exception If the SSL_CONF context could not be created
39 | *
40 | * @see OpenSSL SSL_CONF_CTX_new
41 | * @see OpenSSL
42 | * SSL_CONF_CTX_set_flags
43 | */
44 | public static native long make(long pool, int flags) throws Exception;
45 |
46 | /**
47 | * Free the resources used by the context
48 | *
49 | * @param cctx SSL_CONF context to free.
50 | *
51 | * @see OpenSSL SSL_CONF_CTX_free
52 | */
53 | public static native void free(long cctx);
54 |
55 | /**
56 | * Check a command with an SSL_CONF context.
57 | *
58 | * @param cctx SSL_CONF context to use.
59 | * @param name command name.
60 | * @param value command value.
61 | *
62 | * @return The result of the check based on the {@code SSL_CONF_cmd_value_type} call. Unknown types will result in
63 | * an exception, as well as file and directory types with invalid file or directory names.
64 | *
65 | * @throws Exception If the check fails.
66 | *
67 | * @see OpenSSL SSL_CONF_cmd_value_type
68 | */
69 | public static native int check(long cctx, String name, String value) throws Exception;
70 |
71 | /**
72 | * Assign an SSL context to an SSL_CONF context. All following calls to {@link #apply(long, String, String)} will be
73 | * applied to this SSL context.
74 | *
75 | * @param cctx SSL_CONF context to use.
76 | * @param ctx SSL context to assign to the given SSL_CONF context.
77 | *
78 | * @see OpenSSL
79 | * SSL_CONF_CTX_set_ssl_ctx
80 | */
81 | public static native void assign(long cctx, long ctx);
82 |
83 | /**
84 | * Apply a command to an SSL_CONF context.
85 | *
86 | * @param cctx SSL_CONF context to use.
87 | * @param name command name.
88 | * @param value command value.
89 | *
90 | * @return The result of the native {@code SSL_CONF_cmd} call
91 | *
92 | * @throws Exception If the SSL_CONF context is {@code 0}
93 | *
94 | * @see OpenSSL SSL_CONF_cmd
95 | */
96 | public static native int apply(long cctx, String name, String value) throws Exception;
97 |
98 | /**
99 | * Finish commands for an SSL_CONF context.
100 | *
101 | * @param cctx SSL_CONF context to use.
102 | *
103 | * @return The result of the native {@code SSL_CONF_CTX_finish} call
104 | *
105 | * @see OpenSSL
106 | * SSL_CONF_CTX_finish
107 | */
108 | public static native int finish(long cctx);
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/java/org/apache/tomcat/jni/Sockaddr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.tomcat.jni;
18 |
19 | /**
20 | * Tomcat Native 1.2.33 and earlier won't initialise unless this class is present. This dummy class ensures
21 | * initialisation gets as far as being able to check the version of the Tomcat Native library and reporting a version
22 | * error if 1.2.33 or earlier is present.
23 | */
24 | public class Sockaddr {
25 |
26 | private Sockaddr() {
27 | // Hide default constructor
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/java/overview.html:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 | Overview Documentation for Tomcat Native
23 |
24 |
25 |
The Tomcat Native Library component of the Apache Tomcat
26 | Connectors project offers a JNI wrapper around OpenSSL allowing it to
27 | be used with Tomcat for TLS connections instead of JSSE.
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/jnirelease.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Licensed to the Apache Software Foundation (ASF) under one or more
4 | # contributor license agreements. See the NOTICE file distributed with
5 | # this work for additional information regarding copyright ownership.
6 | # The ASF licenses this file to You under the Apache License, Version 2.0
7 | # (the "License"); you may not use this file except in compliance with
8 | # the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | #
20 | # BEFORE releasing don't forget to edit and commit
21 | # native/include/tcn_version.h
22 | # native/os/win32/libtcnative.rc
23 |
24 | # Default place to look for apr source. Can be overridden with
25 | # --with-apr=[directory]
26 | apr_src_dir=`pwd`/native/srclib/apr
27 |
28 | GITBASE=https://gitbox.apache.org/repos/asf/tomcat-native.git
29 | TCJAVA_GITBASE=https://gitbox.apache.org/repos/asf/tomcat.git
30 |
31 | # Set the environment variable that stops OSX storing extended
32 | # attributes in tar archives etc. with a file starting with ._
33 | COPYFILE_DISABLE=1
34 | export COPYFILE_DISABLE
35 |
36 | JKJNIEXT=""
37 | JKJNIHASH=""
38 | JKJNIVER=""
39 | JKJNIREL=""
40 | JKJNIFORCE=""
41 |
42 | for o
43 | do
44 | case "$o" in
45 | -*=*) a=`echo "$o" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
46 | *) a='' ;;
47 | esac
48 | case "$o" in
49 | -f )
50 | JKJNIFORCE=1
51 | shift
52 | ;;
53 | --ver*=* )
54 | JKJNIEXT="$a"
55 | shift
56 | ;;
57 | --with-apr=* )
58 | apr_src_dir="$a" ;
59 | shift ;;
60 | * )
61 | echo ""
62 | echo "Usage: jnirelease.sh [options]"
63 | echo " --ver[sion]= Tomcat Native version"
64 | echo " --with-apr= APR sources directory"
65 | echo ""
66 | exit 1
67 | ;;
68 | esac
69 | done
70 |
71 |
72 | if [ -d "$apr_src_dir" ]; then
73 | echo ""
74 | echo "Using apr source from: \`$apr_src_dir'"
75 | else
76 | echo ""
77 | echo "Problem finding apr source in: \`$apr_src_dir'"
78 | echo "Use:"
79 | echo " --with-apr="
80 | echo ""
81 | exit 1
82 | fi
83 |
84 | if [ "x$JKJNIEXT" = "x" ]; then
85 | echo ""
86 | echo "Unknown Git tag/branch"
87 | echo "Use:"
88 | echo " --ver=|1.1.x|1.2.x|1.3.x|main|."
89 | echo ""
90 | exit 1
91 | fi
92 |
93 | # Check for links, elinks or w3m
94 | w3m_opts="-dump -cols 80 -t 4 -S -O iso-8859-1 -T text/html"
95 | elinks_opts="-dump -dump-width 80 -dump-charset iso-8859-1 -no-numbering -no-references -no-home"
96 | links_opts="-dump -width 80 -codepage iso-8859-1 -no-g -html-numbered-links 0"
97 | EXPTOOL=""
98 | EXPOPTS=""
99 | for i in w3m elinks links
100 | do
101 | EXPTOOL="`which $i 2>/dev/null || type $i 2>&1`"
102 | if [ -x "$EXPTOOL" ]; then
103 | case ${i} in
104 | w3m)
105 | EXPOPTS="${w3m_opts}"
106 | ;;
107 | elinks)
108 | EXPOPTS="${elinks_opts}"
109 | ;;
110 | links)
111 | EXPOPTS="${links_opts}"
112 | ;;
113 | esac
114 | echo "Using: ${EXPTOOL} ${EXPOPTS} ..."
115 | break
116 | fi
117 | done
118 | if [ ! -x "$EXPTOOL" ]; then
119 | echo ""
120 | echo "Cannot find html export tool"
121 | echo "Make sure you have either w3m elinks or links in the PATH"
122 | echo ""
123 | exit 1
124 | fi
125 | PERL="`which perl 2>/dev/null || type perl 2>&1`"
126 | if [ -x "$PERL" ]; then
127 | echo "Using $PERL"
128 | else
129 | echo ""
130 | echo "Cannot find perl"
131 | echo "Make sure you have perl in the PATH"
132 | echo ""
133 | exit 1
134 | fi
135 |
136 | if [ "x$JKJNIEXT" = "xmain" ]; then
137 | JKJNIHASH=`git ls-remote $GITBASE refs/heads/main | awk '{print $1}'`
138 | JKJNIVER="$JKJNIEXT-$JKJNIHASH"
139 | elif [ "x$JKJNIEXT" = "x1.3.x" ]; then
140 | JKJNIHASH=`git ls-remote $GITBASE refs/heads/1.3.x | awk '{print $1}'`
141 | JKJNIVER="$JKJNIEXT-$JKJNIHASH"
142 | elif [ "x$JKJNIEXT" = "x1.2.x" ]; then
143 | JKJNIHASH=`git ls-remote $GITBASE refs/heads/1.2.x | awk '{print $1}'`
144 | JKJNIVER="$JKJNIEXT-$JKJNIHASH"
145 | elif [ "x$JKJNIEXT" = "x1.1.x" ]; then
146 | JKJNIHASH=`git ls-remote $GITBASE refs/heads/1.1.x | awk '{print $1}'`
147 | JKJNIVER="$JKJNIEXT-$JKJNIHASH"
148 | elif [ "x$JKJNIEXT" = "x." ]; then
149 | JKJNIHASH=`git rev-parse --short HEAD`
150 | JKJNIVER="HEAD-$JKJNIHASH"
151 | else
152 | JKJNIHASH=`git ls-remote $GITBASE refs/tags/$JKJNIEXT | awk '{print $1}'`
153 | JKJNIVER="$JKJNIEXT"
154 | JKJNIREL=1
155 | fi
156 | echo "Using GIT repo : \`${GITBASE}\`"
157 | echo "Using version : \`${JKJNIVER}\`"
158 |
159 | if [ ! -d .git ]; then
160 | rm -rf tmp-clone
161 | git clone --no-checkout $GITBASE tmp-clone
162 | mv tmp-clone/.git .
163 | rm -rf tmp-clone
164 | # Checking for recentness of git subtree
165 | git checkout --force ${JKJNIHASH}
166 | else
167 | # Checking for recentness of git subtree
168 | git checkout ${JKJNIHASH}
169 | fi
170 |
171 | if [ ! -d .git/refs/remotes/tcjava ]; then
172 | git remote add -f tcjava ${TCJAVA_GITBASE}
173 | fi
174 | git remote update tcjava
175 | diffcount=`git diff HEAD remotes/tcjava/main java/org/apache/tomcat/jni | wc -l`
176 |
177 | if [ $diffcount -ne 0 ]; then
178 | echo "WARNING: git subtree is not up to date with"
179 | echo " $TCJAVA_GITBASE"
180 | echo " Either correct now by running"
181 | echo " 'git checkout main'"
182 | echo " 'git rm -rf java/org/apache/tomcat/jni'"
183 | echo " 'git read-tree --prefix=java/org/apache/tomcat/jni/ -u tcjava/main:java/org/apache/tomcat/jni'"
184 | echo " 'git commit'"
185 | echo " or run this script with -f (force)"
186 | if [ "X$JKJNIFORCE" = "X1" ]
187 | then
188 | sleep 3
189 | echo "FORCED run chosen"
190 | else
191 | exit 1
192 | fi
193 | fi
194 |
195 | JKJNIDIST=tomcat-native-${JKJNIVER}-src
196 |
197 | rm -rf ${JKJNIDIST}
198 | mkdir -p ${JKJNIDIST}
199 | git archive ${JKJNIHASH} | tar -x -C ${JKJNIDIST}
200 | if [ $? -ne 0 ]; then
201 | echo ""
202 | echo "git export failed"
203 | echo ""
204 | exit 1
205 | fi
206 | rm -f ${JKJNIDIST}/KEYS ${JKJNIDIST}/download_deps.sh
207 |
208 | # check the release if release.
209 | if [ "x$JKJNIREL" = "x1" ]; then
210 | grep TCN_IS_DEV_VERSION ${JKJNIDIST}/native/include/tcn_version.h | grep 0
211 | if [ $? -ne 0 ]; then
212 | echo "Check: ${JKJNIDIST}/native/include/tcn_version.h says -dev"
213 | echo "Check TCN_IS_DEV_VERSION - Aborting"
214 | exit 1
215 | fi
216 | WIN_VERSION=`grep TCN_VERSION ${JKJNIDIST}/native/os/win32/libtcnative.rc | grep define | awk ' { print $3 } '`
217 | if [ "x\"$JKJNIVER\"" != "x$WIN_VERSION" ]; then
218 | echo "Check: ${JKJNIDIST}/native/os/win32/libtcnative.rc says $WIN_VERSION (FILEVERSION, PRODUCTVERSION, TCN_VERSION)"
219 | echo "Must be $JKJNIVER - Aborting"
220 | exit 1
221 | fi
222 | else
223 | echo "Not a release"
224 | fi
225 |
226 | top="`pwd`"
227 | cd ${JKJNIDIST}/xdocs
228 |
229 | # Make docs
230 | ant
231 | if [ $? -ne 0 ]; then
232 | echo ""
233 | echo "ant (building docs failed)"
234 | echo ""
235 | exit 1
236 | fi
237 |
238 | $EXPTOOL $EXPOPTS ../build/docs/miscellaneous/changelog.html > ../CHANGELOG.txt 2>/dev/null
239 | if [ $? -ne 0 ]; then
240 | echo ""
241 | echo "$EXPTOOL $EXPOPTS ../build/docs/miscellaneous/changelog.html failed"
242 | echo ""
243 | exit 1
244 | fi
245 | # Remove page navigation data from converted file.
246 | cp -p ../CHANGELOG.txt ../CHANGELOG.txt.tmp
247 | awk '/Preface/ {o=1} o>0' ../CHANGELOG.txt.tmp > ../CHANGELOG.txt
248 | rm ../CHANGELOG.txt.tmp
249 |
250 | cd "$top"
251 | mv ${JKJNIDIST}/build/docs ${JKJNIDIST}/docs
252 | rm -rf ${JKJNIDIST}/build
253 |
254 | # Prebuild (create configure)
255 | cd ${JKJNIDIST}/native
256 | ./buildconf --with-apr=$apr_src_dir || exit 1
257 |
258 | cd "$top"
259 | # Create source distribution
260 | tar -cf - ${JKJNIDIST} | gzip -c9 > ${JKJNIDIST}.tar.gz || exit 1
261 |
262 | # Create Win32 source distribution
263 | JKWINDIST=tomcat-native-${JKJNIVER}-win32-src
264 | rm -rf ${JKWINDIST}
265 | mkdir -p ${JKWINDIST}
266 | git -c core.autocrlf=true -c core.eol=crlf archive ${JKJNIHASH} | tar -x -C ${JKWINDIST}
267 | if [ $? -ne 0 ]; then
268 | echo ""
269 | echo "git export failed"
270 | echo ""
271 | exit 1
272 | fi
273 | rm -f ${JKWINDIST}/KEYS ${JKWINDIST}/download_deps.sh
274 |
275 | top="`pwd`"
276 | cd ${JKWINDIST}/xdocs
277 |
278 | # Make docs
279 | ant
280 | if [ $? -ne 0 ]; then
281 | echo ""
282 | echo "ant (building docs failed)"
283 | echo ""
284 | exit 1
285 | fi
286 |
287 | cd "$top"
288 | cp ${JKJNIDIST}/CHANGELOG.txt ${JKWINDIST}
289 |
290 | mv ${JKWINDIST}/build/docs ${JKWINDIST}/docs
291 | rm -rf ${JKWINDIST}/build
292 | for i in LICENSE NOTICE README.txt
293 | do
294 | $PERL ${JKWINDIST}/native/build/lineends.pl --cr ${JKWINDIST}/${i}
295 | done
296 | $PERL ${JKWINDIST}/native/build/lineends.pl --cr ${JKWINDIST}/CHANGELOG.txt
297 |
298 | zip -9rqyo ${JKWINDIST}.zip ${JKWINDIST}
299 |
--------------------------------------------------------------------------------
/native/BUILDING:
--------------------------------------------------------------------------------
1 | ================================================================================
2 | Licensed to the Apache Software Foundation (ASF) under one or more
3 | contributor license agreements. See the NOTICE file distributed with
4 | this work for additional information regarding copyright ownership.
5 | The ASF licenses this file to You under the Apache License, Version 2.0
6 | (the "License"); you may not use this file except in compliance with
7 | the License. You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | ================================================================================
17 |
18 | Linux / Unix / OSX (dynamic linking)
19 | ====================================
20 |
21 | 1. Prerequisites
22 |
23 | Install OpenSSL version 3.0.0 or higher
24 | Install APR version 1.7.0 or higher.
25 | C compiler (e.g. GCC, clang, etc.), autoconf and/or automake
26 | Download and expand the source package or use an git checkout
27 |
28 | > cd native
29 |
30 | 2. Configure build environment
31 |
32 | Note: This step is only required if you are building from an git checkout. It
33 | is not required when building from a source package.
34 |
35 | > sh buildconf --with-apr=apr_source_location.
36 |
37 | 3. Build
38 |
39 | > configure --with-apr=apr_install_location --with-ssl=openssl_install_location
40 | > make
41 |
42 | This should produce a file named libtcnative-2.so
43 |
44 |
45 | Linux / Unix / OSX (static linking)
46 | ===================================
47 |
48 | 1. Build static version of OpenSSL 3.0.0 or later
49 |
50 | > ./Configure --prefix=~/natives/openssl enable-fips
51 | > make
52 | > make install
53 |
54 | 2. Build static version of APR 1.7.0 or later
55 |
56 | > ./configure --prefix=~/natives/apr
57 | > make
58 | > make install
59 |
60 | Note: APR builds both static and dynamic libraries by default.
61 |
62 | 3. Ensure the static APR library is used
63 |
64 | Edit the ~/natives/apr/lib/libapr-1.la file and comment or delete the
65 | following sections: dlname='...' and library_names='...'
66 | This is needed so that libtool picks the static version of the library.
67 |
68 | 4. Build tc-native
69 |
70 | > ./configure --with-apr=~/natives/apr --with-ssl=~/natives/openssl --prefix=~/natives/tomcat
71 | > make
72 | > make install
73 |
74 |
75 | Windows
76 | =======
77 |
78 | 1. Prerequisites
79 |
80 | Currently supported Windows OS (release builds use a Windows 2022 VM running
81 | on VMware)
82 | Currently support JDK installed (release builds use Temurin 21.0.7)
83 | git (if you wish to build from source)
84 | Perl - see OpenSSL build instructions for Windows (release builds use
85 | Strawberry Perl 5.40.2001)
86 | NASM - see OpenSSL build instructions for Windows (release builds use 2.16.01
87 | included in Strawberry Perl 5.40.2001)
88 | Microsoft Visual C compiler (release builds use Visual Studio 2022 17.1.4.1)
89 |
90 | 2. Obtain tc-native source
91 |
92 | Download and expand the source package or use an git checkout
93 |
94 | 3. Build APR
95 |
96 | Unpack the APR source distribution into native\srclib\apr
97 |
98 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
99 | > nmake -f NMAKEmakefile CPU=X86 APR_DECLARE_STATIC=1
100 |
101 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
102 | > nmake -f NMAKEmakefile CPU=X64 APR_DECLARE_STATIC=1
103 |
104 | 4. Build OpenSSL
105 |
106 | > cd ..\openssl
107 |
108 | Unpack the OpenSSL 3.5.x source distribution in this directory
109 |
110 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
111 | > perl Configure no-shared VC-WIN32
112 | > nmake
113 | > mkdir out32-x86
114 | > copy libssl.lib out32-x86\
115 | > copy libcrypto.lib out32-x86\
116 | > copy ossl_static.lib out32-x86\
117 | > copy apps\openssl.exe out32-x86\
118 |
119 | > nmake clean
120 |
121 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
122 | > perl Configure no-shared VC-WIN64A
123 | > nmake
124 | > mkdir out32-x64
125 | > copy libssl.lib out32-x64\
126 | > copy libcrypto.lib out32-x64\
127 | > copy ossl_static.lib out32-x64\
128 | > copy apps\openssl.exe out32-x64\
129 |
130 | 5. Copy APR and OpenSSL to versioned directories
131 |
132 | Keeping the various libraries in versioned directories saves having to
133 | rebuild them next time if the version remains unchanged.
134 |
135 | > cd ..
136 | > set OPENSSL_VER=3.5.0
137 | > set APR_VER=1.7.6
138 |
139 | > mkdir \deps-x86\apr-%APR_VER%\include
140 | > mkdir \deps-x86\apr-%APR_VER%\lib
141 | > mkdir \deps-x86\openssl-%OPENSSL_VER%\include
142 | > mkdir \deps-x86\openssl-%OPENSSL_VER%\lib
143 | > xcopy /E \deps-x86\apr-%APR_VER% \deps-x64\apr-%APR_VER%\
144 | > xcopy /E \deps-x86\openssl-%OPENSSL_VER% \deps-x64\openssl-%OPENSSL_VER%\
145 |
146 | > xcopy /E apr\include \deps-x86\apr-%APR_VER%\include\
147 | > xcopy /E apr\include \deps-x64\apr-%APR_VER%\include\
148 |
149 | > copy apr\WIN7_X86_LIB_RELEASE\apr-1.lib \deps-x86\apr-%APR_VER%\lib
150 | > copy apr\WIN7_X64_LIB_RELEASE\apr-1.lib \deps-x64\apr-%APR_VER%\lib
151 |
152 | > xcopy /E openssl\include\openssl \deps-x86\openssl-%OPENSSL_VER%\include\openssl\
153 | > xcopy /E openssl\include\openssl \deps-x64\openssl-%OPENSSL_VER%\include\openssl\
154 | > copy openssl\out32-x86\*.lib \deps-x86\openssl-%OPENSSL_VER%\lib\
155 | > copy openssl\out32-x64\*.lib \deps-x64\openssl-%OPENSSL_VER%\lib\
156 | > copy openssl\out32-x86\*.pdb \deps-x86\openssl-%OPENSSL_VER%\lib\
157 | > copy openssl\out32-x64\*.pdb \deps-x64\openssl-%OPENSSL_VER%\lib\
158 | > copy openssl\out32-x86\openssl.exe \deps-x86\openssl-%OPENSSL_VER%\
159 | > copy openssl\out32-x64\openssl.exe \deps-x64\openssl-%OPENSSL_VER%\
160 |
161 |
162 | 6. Build Tomcat Native
163 |
164 | > cd ..
165 | >set JAVA_HOME=C:\java\21.0.7-tem
166 |
167 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
168 | > nmake -f NMAKEMakefile WITH_APR=C:\deps-x86\apr-%APR_VER% WITH_OPENSSL=C:\deps-x86\openssl-%OPENSSL_VER% CPU=X86 APR_DECLARE_STATIC=1 STATIC_CRT=Hybrid OPENSSL_NEW_LIBS=1 ENABLE_OCSP=1
169 | > move WIN7_X86_DLL_RELEASE WIN7_X86_OCSP_DLL_RELEASE
170 | > nmake -f NMAKEMakefile WITH_APR=C:\deps-x86\apr-%APR_VER% WITH_OPENSSL=C:\deps-x86\openssl-%OPENSSL_VER% CPU=X86 APR_DECLARE_STATIC=1 STATIC_CRT=Hybrid OPENSSL_NEW_LIBS=1
171 |
172 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
173 | > nmake -f NMAKEMakefile WITH_APR=C:\deps-x64\apr-%APR_VER% WITH_OPENSSL=C:\deps-x64\openssl-%OPENSSL_VER% CPU=X64 APR_DECLARE_STATIC=1 STATIC_CRT=Hybrid OPENSSL_NEW_LIBS=1 ENABLE_OCSP=1
174 | > move WIN7_X64_DLL_RELEASE WIN7_X64_OCSP_DLL_RELEASE
175 | > nmake -f NMAKEMakefile WITH_APR=C:\deps-x64\apr-%APR_VER% WITH_OPENSSL=C:\deps-x64\openssl-%OPENSSL_VER% CPU=X64 APR_DECLARE_STATIC=1 STATIC_CRT=Hybrid OPENSSL_NEW_LIBS=1
176 |
177 | Tomcat Native Connector DLLs may then be found in native\WIN7_*_[OCSP_]DLL_RELEASE
178 |
179 |
180 | FIPS
181 | ====
182 |
183 | No additional build steps are required. Configure OpenSSL to use the FIPS
184 | certified provider as the default provider as described in the OpenSSL
185 | documentation:
186 |
187 | https://www.openssl.org/docs/man3.0/man7/fips_module.html
188 |
--------------------------------------------------------------------------------
/native/Makefile.in:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | #
19 | # Top-level Makefile for TCNATIVE
20 | #
21 |
22 | CFLAGS = @CFLAGS@
23 | CPPFLAGS = @CPPFLAGS@
24 |
25 | # gets substituted into some targets
26 | TCNATIVE_MAJOR_VERSION=@TCNATIVE_MAJOR_VERSION@
27 | TCNATIVE_DOTTED_VERSION=@TCNATIVE_DOTTED_VERSION@
28 | TCNATIVE_LIBTOOL_VERSION=@TCNATIVE_LIBTOOL_VERSION@
29 |
30 | srcdir = @srcdir@
31 | VPATH = @srcdir@
32 |
33 | # this sucks, but it's the only way to add extra flags to the LT_COMPILE
34 | INCLUDES = @CFLAGS@ @CPPFLAGS@ @TCNATIVE_INCLUDES@ @TCNATIVE_PRIV_INCLUDES@ @APR_INCLUDES@
35 | TCNATIVE_LDFLAGS = @TCNATIVE_LDFLAGS@
36 | TCNATIVE_LIBS = @TCNATIVE_LIBS@
37 |
38 | TARGET_LIB = lib@TCNATIVE_LIBNAME@.la
39 | EXTRA_OS_LINK=@EXTRA_OS_LINK@
40 | INSTALL = @INSTALL@
41 | INSTALL_DATA = @INSTALL_DATA@
42 |
43 | TARGETS = $(TARGET_LIB)
44 |
45 | # bring in rules.mk for standard functionality
46 | @INCLUDE_RULES@
47 | @INCLUDE_OUTPUTS@
48 |
49 | LINK = $(LIBTOOL) $(LTFLAGS) --mode=link --tag=CC $(LT_LDFLAGS) $(COMPILE) -version-info $(TCNATIVE_LIBTOOL_VERSION) $(ALL_LDFLAGS) -o $@
50 | CLEAN_SUBDIRS = test
51 |
52 | CLEAN_TARGETS = .make.dirs
53 | DISTCLEAN_TARGETS = config.cache config.log config.status \
54 | build/rules.mk
55 | EXTRACLEAN_TARGETS = configure aclocal.m4 build-outputs.mk \
56 | build/apr_common.m4 build/find_apr.m4 build/install.sh \
57 | build/config.guess build/config.sub tcnative.spec
58 |
59 | prefix=@prefix@
60 | exec_prefix=@exec_prefix@
61 | libdir=@libdir@
62 | top_srcdir=@abs_srcdir@
63 | top_blddir=@abs_builddir@
64 |
65 |
66 | install: $(TARGET_LIB)
67 | $(APR_MKDIR) $(DESTDIR)$(libdir)
68 | $(LIBTOOL) --mode=install $(INSTALL) -m 755 $(TARGET_LIB) $(DESTDIR)$(libdir)
69 |
70 | $(TARGET_LIB): $(OBJECTS)
71 | $(LINK) @lib_target@ $(TCNATIVE_LDFLAGS) $(TCNATIVE_LIBS)
72 |
73 | check: $(TARGET_LIB)
74 | (cd test && $(MAKE) check)
75 |
--------------------------------------------------------------------------------
/native/NMAKEmakefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 | # ====================================================================
17 | #
18 | # NMAKEmakefile Tomcat Native makefile.
19 | # Usage:
20 | # APR_DECLARE_STATIC=1 Use static version of the APR
21 | # ENABLE_OCSP=1 Enable OpenSSL OCSP code
22 | # OPENSSL_NEW_LIBS=1 Use new OpenSSL lib file names
23 | # DEBUG=1 Build DEBUG version of TCN
24 | # STATIC_CRT=Hybrid Build using the 'Hybrid CRT' technique
25 | #
26 | # Originally contributed by Mladen Turk
27 | #
28 | # ====================================================================
29 | #
30 |
31 | !IF !DEFINED(APR_DECLARE_STATIC) || "$(APR_DECLARE_STATIC)" == ""
32 | PROJECT = libtcnative-2
33 | !ELSE
34 | PROJECT = tcnative-2
35 | !ENDIF
36 | TARGET = DLL
37 |
38 | !include
39 |
40 | !IF !DEFINED(APR_DECLARE_STATIC) || "$(APR_DECLARE_STATIC)" == ""
41 | APR_LIB = libapr-1.lib
42 | !ELSE
43 | CFLAGS = $(CFLAGS) -DAPR_DECLARE_STATIC
44 | APR_LIB = apr-1.lib
45 | !ENDIF
46 | !IF !DEFINED(ENABLE_OCSP)
47 | CFLAGS = $(CFLAGS) -DOPENSSL_NO_OCSP
48 | !ENDIF
49 |
50 | !IF !DEFINED(SRCDIR) || "$(SRCDIR)" == ""
51 | SRCDIR = .
52 | !ENDIF
53 |
54 | INCLUDES = -I$(SRCDIR)\include $(JAVA_INCLUDES)
55 |
56 | !IFNDEF WITH_APR
57 | WITH_APR = $(SRCDIR)\srclib\apr
58 | LDIRS = /libpath:"$(WITH_APR)\$(WORKDIR)"
59 | !ELSE
60 | LDIRS = /libpath:"$(WITH_APR)\lib"
61 | !ENDIF
62 |
63 | INCLUDES = $(INCLUDES) -I$(WITH_APR)\include -I$(WITH_APR)\include\arch\win32
64 | !IF DEFINED(WITH_OPENSSL)
65 | INCLUDES = $(INCLUDES) -I$(WITH_OPENSSL)\include
66 | LDIRS = $(LDIRS) /libpath:"$(WITH_OPENSSL)\lib"
67 | !ELSE
68 | WITH_OPENSSL = $(SRCDIR)\srclib\openssl
69 | INCLUDES = $(INCLUDES) -I$(WITH_OPENSSL)\inc32
70 | LDIRS = $(LDIRS) /libpath:"$(WITH_OPENSSL)\out32"
71 | !ENDIF
72 |
73 | LFLAGS = $(LFLAGS) /version:2.0
74 | LIBS = $(LIBS) user32.lib gdi32.lib $(APR_LIB)
75 | !IF DEFINED(WITH_FIPS)
76 | LIBS = $(LIBS) libeayfips32.lib libeaycompat32.lib ssleay32.lib
77 | LFLAGS = $(LFLAGS) /NODEFAULTLIB:LIBCMT
78 | !ELSE
79 | !IF DEFINED(OPENSSL_NEW_LIBS)
80 | LIBS = $(LIBS) libssl.lib libcrypto.lib crypt32.lib
81 | !ELSE
82 | LIBS = $(LIBS) libeay32.lib ssleay32.lib
83 | !ENDIF
84 | !ENDIF
85 |
86 | CFLAGS = $(CFLAGS) -DZLIB_WINAPI -DNO_IDEA -DNO_RC5 -DNO_MDC2 -DOPENSSL_NO_IDEA \
87 | -DOPENSSL_NO_RC5 -DOPENSSL_NO_MDC2 -DHAVE_SSL_SET_STATE=1
88 |
89 |
90 | PDBFLAGS = -Fo$(WORKDIR)\ -Fd$(WORKDIR)\$(PROJECT)
91 | OBJECTS = \
92 | $(WORKDIR)\bb.obj \
93 | $(WORKDIR)\error.obj \
94 | $(WORKDIR)\jnilib.obj \
95 | $(WORKDIR)\pool.obj \
96 | $(WORKDIR)\ssl.obj \
97 | $(WORKDIR)\sslcontext.obj \
98 | $(WORKDIR)\sslconf.obj \
99 | $(WORKDIR)\sslutils.obj \
100 | $(WORKDIR)\system.obj
101 |
102 | !IF DEFINED(WITH_FIPS)
103 | OBJECTS = $(OBJECTS) srclib\openssl\tmp32\fips_premain.obj
104 | !ENDIF
105 |
106 | !IF DEFINED(WITH_FIPS)
107 | FIPS_OPTS = /map
108 | LINK_WRAPPER = perl $(FIPSDIR)\bin\fipslink.pl
109 | !ELSE
110 | LINK_WRAPPER = $(LINK)
111 | !ENDIF
112 |
113 | BUILDLIB = $(PREFIX)\lib
114 | BUILDBIN = $(WORKDIR)\$(PROJECT).dll
115 | BUILDPDB = $(WORKDIR)\$(PROJECT).pdb
116 | BUILDRES = $(WORKDIR)\$(PROJECT).res
117 |
118 | all : $(WORKDIR) $(BUILDBIN)
119 |
120 | $(WORKDIR):
121 | @$(MAKEWORKDIR)
122 |
123 | {$(SRCDIR)\src}.c{$(WORKDIR)}.obj:
124 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
125 |
126 | {$(SRCDIR)\os\win32}.c{$(WORKDIR)}.obj:
127 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
128 |
129 | $(BUILDRES): $(SRCDIR)\os\win32\libtcnative.rc
130 | $(RC) $(RCFLAGS) /i "$(SRCDIR)\include" /fo $(BUILDRES) $**
131 |
132 | $(BUILDBIN): $(OBJECTS) $(BUILDRES)
133 | SET FIPSLINK=perl $(FIPSDIR)\bin\fipslink.pl
134 | SET FIPS_LINK=$(LINK)
135 | SET FIPS_CC=$(CC)
136 | SET FIPS_CC_ARGS=/Fosrclib\openssl\tmp32\fips_premain.obj /MD -c
137 | SET PREMAIN_DSO_EXE=srclib\openssl\out32\fips_premain_dso.exe
138 | SET FIPS_TARGET=$(BUILDBIN)
139 | SET FIPS_SHA1_EXE=$(FIPSDIR)\bin\fips_standalone_sha1.exe
140 | SET FIPSLIB_D=$(FIPSDIR)\lib
141 | $(LINK_WRAPPER) $(LFLAGS) $(LDIRS) $** $(LIBS) /pdb:$(BUILDPDB) $(FIPS_OPTS) /out:$(BUILDBIN)
142 |
143 | clean:
144 | @$(CLEANTARGET)
145 |
146 | install: all
147 | @xcopy /I /Y /Q "$(WORKDIR)\*.lib" "$(BUILDLIB)"
148 | @xcopy /I /Y /Q "$(WORKDIR)\*.dll" "$(BUILDLIB)"
149 |
--------------------------------------------------------------------------------
/native/NMAKEmakefile.inc:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 | # @author Mladen Turk
17 | #
18 | #
19 | # ====================================================================
20 | #
21 | # Makefile.inc Tomcat Native makefile definitions.
22 | # This file defines CPU architecture and basic compiler
23 | # and linker parameters.
24 | # Common params:
25 | # CPU Compile for specified CPU. Supported CPU's are:
26 | # X86 (Common x86 architecture)
27 | # X64 (AMD64/EMT64 architecture)
28 | # I64 (Intel IA64 architecture)
29 | # If not specified it will default to the
30 | # PROCESSOR_ARCHITECTURE environment variable
31 | # or to the X86 if not specified.
32 | # WINVER Compile for specified Windows version
33 | # WIN10 for Windows 10 and up
34 | # WIN81 for Windows 8.1 and up
35 | # WIN8 for Windows 8 and up
36 | # WIN7 for Windows 7 and up (default)
37 | # Deprecated targets (may not even compile):
38 | # VISTA for Windows Vista / Server 2008 and up
39 | # WIN2003 for Windows 2003 and up
40 | # WINXP for Windows XP and up
41 | # WIN2K for Windows 2000 and up
42 | # BUILD Build version
43 | # RETAIL or RELEASE (default)
44 | # DEBUG
45 | # TARGET Build application target
46 | # EXE Console executable (default)
47 | # GUI Windows GUI executable
48 | # DLL Dynamic Link Library
49 | # LIB Static library
50 | # UNICODE Build unicode version
51 | # If definded and not empty -D_UNICODE is added
52 | # to CFLAGS; -D_MBCS is added otherwise
53 | # Environment variables used:
54 | # EXTRA_CFLAGS Added to the common CFLAGS
55 | # EXTRA_CXXFLAGS Added to the common CXXFLAGS
56 | # EXTRA_LIBS Added to the common LIBS
57 | # EXTRA_LFLAGS Added to the common LFLAGS
58 | # EXTRA_RCFLAGS Added to the common RCFLAGS
59 | #
60 | # Compiler tools environment variables:
61 | # CC C compiler (defaults to cl.exe)
62 | # CXX C++ compiler (defaults to $CC -TP)
63 | # CPP C preprocessor (defaults to $CC -EP)
64 | # LINK Linker (defaults to link.exe)
65 | # RC Resource compiler (defaults to rc.exe)
66 | # MT Manifest toolkit (defaults to mt.exe)
67 | # ML Assembler (defaults to ml.exe or ml64.exe)
68 | #
69 | # Originally contributed by Mladen Turk
70 | #
71 | # ====================================================================
72 | #
73 |
74 | # C/C++ compiler
75 | !IF !DEFINED(CC) || "$(CC)" == ""
76 | CC = cl.exe
77 | !ENDIF
78 | !IF !DEFINED(CXX) || "$(CXX)" == ""
79 | CXX = $(CC) -TP
80 | !ENDIF
81 | !IF !DEFINED(CPP) || "$(CPP)" == ""
82 | CPP = $(CC) -EP
83 | !ENDIF
84 | # Linker
85 | !IF !DEFINED(LINK) || "$(LINK)" == ""
86 | LINK = link.exe
87 | !ENDIF
88 | # Resource Compiler
89 | !IF !DEFINED(RC) || "$(RC)" == ""
90 | RC = rc.exe
91 | !ENDIF
92 | # Manifest toolkit
93 | !IF !DEFINED(MT) || "$(MT)" == ""
94 | MT = mt.exe
95 | !ENDIF
96 |
97 | # Use BUILD_CPU if CPU was not set
98 | !IF !DEFINED(CPU) || "$(CPU)" == ""
99 | !IF "$(BUILD_CPU)" == "i386" || "$(BUILD_CPU)" == "x86" || "$(BUILD_CPU)" == "i686"
100 | CPU=X86
101 | !ENDIF
102 | !IF "$(BUILD_CPU)" == "amd64" || "$(BUILD_CPU)" == "x86_64" || "$(BUILD_CPU)" == "x64"
103 | CPU=X64
104 | !ENDIF
105 | !IF "$(BUILD_CPU)" == "ia64" || "$(BUILD_CPU)" == "i64"
106 | CPU=I64
107 | !ENDIF
108 | !ENDIF
109 | # Figure out CPU from the current host
110 | !IF !DEFINED(CPU) || "$(CPU)" == ""
111 | !IF "$(PROCESSOR_ARCHITECTURE)" == ""
112 | !IF "$(PROCESSOR_ARCHITEW6432)" == ""
113 | CPU=X86
114 | !ELSE
115 | CPU=$(PROCESSOR_ARCHITEW6432)
116 | !ENDIF
117 | !ELSE
118 | !IF "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
119 | CPU=X64
120 | !ELSE
121 | CPU=$(PROCESSOR_ARCHITECTURE)
122 | !ENDIF
123 | !ENDIF
124 | !ENDIF
125 |
126 | !IF "$(CPU)" != "X86"
127 | !IF "$(CPU)" != "X64"
128 | !IF "$(CPU)" != "I64"
129 | !ERROR Must specify CPU environment variable (X86, X64, I64) $(CPU)
130 | !ENDIF
131 | !ENDIF
132 | !ENDIF
133 |
134 | !IF !DEFINED(TARGET) || "$(TARGET)" == ""
135 | TARGET=EXE
136 | !ENDIF
137 |
138 | !IF "$(TARGET)" != "EXE"
139 | !IF "$(TARGET)" != "GUI"
140 | !IF "$(TARGET)" != "DLL"
141 | !IF "$(TARGET)" != "LIB"
142 | !ERROR Must specify TARGET environment variable (EXE, GUI, DLL, LIB)
143 | !ENDIF
144 | !ENDIF
145 | !ENDIF
146 | !ENDIF
147 |
148 | !IF !DEFINED(WINVER) || "$(WINVER)" == ""
149 | WINVER=WIN7
150 | !ENDIF
151 |
152 |
153 | !IF "$(WINVER)" == "WIN7"
154 | NMAKE_WINVER = 0x0601
155 | !ELSEIF "$(WINVER)" == "WIN8"
156 | NMAKE_WINVER = 0x0602
157 | !ELSEIF "$(WINVER)" == "WIN81"
158 | NMAKE_WINVER = 0x0603
159 | !ELSEIF "$(WINVER)" == "WIN10"
160 | NMAKE_WINVER = 0x0A00
161 | !ELSE
162 | !ERROR Must specify WINVER environment variable (WIN7, WIN8, WIN81, WIN10)
163 | !ENDIF
164 |
165 | NMAKE_WINNT = -DWINNT -D_WINNT -D_WIN32_WINNT=$(NMAKE_WINVER) -DWINVER=$(NMAKE_WINVER)
166 |
167 | !IF !DEFINED(BUILD) || "$(BUILD)" == ""
168 | BUILD=RELEASE
169 | !ENDIF
170 | !IFDEF RELEASE
171 | BUILD=RELEASE
172 | !ENDIF
173 | !IFDEF DEBUG
174 | BUILD=DEBUG
175 | !ENDIF
176 | !IFDEF NODEBUG
177 | BUILD=RELEASE
178 | !ENDIF
179 |
180 | !IF "$(BUILD)" != "RELEASE"
181 | !IF "$(BUILD)" != "DEBUG"
182 | !ERROR Must specify BUILD environment variable (RELEASE, DEBUG)
183 | !ENDIF
184 | !ENDIF
185 |
186 | # Common flags for all platforms
187 | CMN_CFLAGS = -c -nologo -DWIN32 -D_WIN32 -D_WINDOWS $(NMAKE_WINNT) -W3
188 | !IF "$(TARGET)" == "EXE"
189 | CMN_CFLAGS = $(CMN_CFLAGS) -D_CONSOLE
190 | !ENDIF
191 | # Mark that extern C newer throws C++ exception
192 | CMN_CFLAGS = $(CMN_CFLAGS) -EHsc
193 |
194 | !IF !DEFINED(UNICODE) || "$(UNICODE)" == ""
195 | CMN_CFLAGS = $(CMN_CFLAGS) -D_MBCS -DMBCS
196 | !ELSE
197 | CMN_CFLAGS = $(CMN_CFLAGS) -D_UNICODE -DUNICODE
198 | !ENDIF
199 | CMN_CFLAGS = $(CMN_CFLAGS) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
200 |
201 | !IF "$(CPU)" == "X86"
202 | CPU_CFLAGS = -D_X86_=1
203 | MACHINE=X86
204 | MACHINE_LC=i386
205 | !ELSEIF "$(CPU)" == "X64"
206 | CPU_CFLAGS = -D_AMD64_=1 -DWIN64 -D_WIN64
207 | MACHINE=AMD64
208 | MACHINE_LC=amd64
209 | !ELSEIF "$(CPU)" == "I64"
210 | CPU_CFLAGS = -D_IA64_=1 -DWIN64 -D_WIN64
211 | MACHINE=IA64
212 | MACHINE_LC=ia64
213 | !ENDIF
214 |
215 | !IF "$(BUILD)" == "RELEASE"
216 | !IF "$(CPU)" == "X86"
217 | OPT_CFLAGS = -O2 -Ob2 -Oy- -Zi -DNDEBUG
218 | !ELSE
219 | OPT_CFLAGS = -O2 -Ob2 -Zi -DNDEBUG
220 | !ENDIF
221 | !ELSE
222 | OPT_CFLAGS = -Od -Zi -DDEBUG -D_DEBUG
223 | !ENDIF
224 |
225 | !IF DEFINED(STATIC_CRT)
226 | CRT_CFLAGS = -D_MT -MT
227 | !ELSE
228 | CRT_CFLAGS = -D_MT -MD
229 | !ENDIF
230 |
231 | !IF "$(BUILD)" == "DEBUG"
232 | CRT_CFLAGS = $(CRT_CFLAGS)d
233 | !ENDIF
234 |
235 | CFLAGS = $(CMN_CFLAGS) $(CPU_CFLAGS) $(OPT_CFLAGS) $(CRT_CFLAGS)
236 |
237 | !IF DEFINED(EXTRA_CFLAGS)
238 | CFLAGS = $(CFLAGS) $(EXTRA_CFLAGS)
239 | !ENDIF
240 |
241 | # Cleanup CXXFLAGS
242 | CXXFLAGS =
243 | !IF DEFINED(EXTRA_CXXFLAGS)
244 | CXXFLAGS = $(EXTRA_CXXFLAGS)
245 | !ENDIF
246 |
247 | # Linker section
248 | LIBS = kernel32.lib advapi32.lib ws2_32.lib shell32.lib rpcrt4.lib
249 | # Extra libs from command line or env
250 | !IF DEFINED(EXTRA_LIBS)
251 | LIBS = $(LIBS) $(EXTRA_LIBS)
252 | !ENDIF
253 |
254 | # Run-Time Error Checks
255 | !IF "$(BUILD)" == "DEBUG"
256 | !IF DEFINED(RTC_CHECK)
257 | LIBS = $(LIBS) RunTmChk.lib
258 | CFLAGS = $(CFLAGS) -RTC1
259 | !ENDIF
260 | !ENDIF
261 |
262 | COMMON_LFLAGS = /NOLOGO /MACHINE:$(MACHINE)
263 |
264 | # Always add debugging to the linker
265 | OPT_LFLAGS = /INCREMENTAL:NO /DEBUG
266 | !IF "$(BUILD)" == "RELEASE"
267 | OPT_LFLAGS = /OPT:REF $(OPT_LFLAGS)
268 | !IF DEFINED(STATIC_CRT) && "$(STATIC_CRT)" == "Hybrid"
269 | OPT_LFLAGS = $(OPT_LFLAGS) /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib
270 | !ENDIF
271 | !ENDIF
272 |
273 | !IF "$(TARGET)" == "EXE"
274 | LFLAGS = $(COMMON_LFLAGS) /SUBSYSTEM:CONSOLE
275 | !ELSEIF "$(TARGET)" == "GUI"
276 | LFLAGS = $(COMMON_LFLAGS) /SUBSYSTEM:WINDOWS
277 | !ELSEIF "$(TARGET)" == "DLL"
278 | LFLAGS = $(COMMON_LFLAGS) /DLL /SUBSYSTEM:WINDOWS
279 | !ELSEIF "$(TARGET)" == "LIB"
280 | LFLAGS = -lib $(COMMON_LFLAGS)
281 | !ENDIF
282 |
283 | !IF DEFINED(EXTRA_LFLAGS)
284 | LFLAGS = $(LFLAGS) $(EXTRA_LFLAGS)
285 | !ENDIF
286 |
287 | !IF "$(TARGET)" != "LIB"
288 | LFLAGS = $(LFLAGS) $(OPT_LFLAGS)
289 | !ENDIF
290 |
291 | # Resource compiler flags
292 |
293 | RCFLAGS=/l 0x409 /n
294 | !IF "$(BUILD)" == "RELEASE"
295 | RCFLAGS = $(RCFLAGS) /d NDEBUG
296 | !ELSE
297 | RCFLAGS = $(RCFLAGS) /d _DEBUG /d DEBUG
298 | !ENDIF
299 | RCFLAGS = $(RCFLAGS) /d WIN32 /d WINNT /d WINVER=$(NMAKE_WINVER) /d _WIN32_WINNT=$(NMAKE_WINVER)
300 | !IF DEFINED(EXTRA_RCFLAGS)
301 | RCFLAGS = $(RCFLAGS) $(EXTRA_RCFLAGS)
302 | !ENDIF
303 |
304 |
305 | # Build Target dir e.g. WINNT_I386_RELEASE_DLL
306 | !IF !DEFINED(WORKDIR) || "$(WORKDIR)" == ""
307 | !IF !DEFINED(WORKDIR_EXT) || "$(WORKDIR_EXT)" == ""
308 | WORKDIR = $(WINVER)_$(CPU)_$(TARGET)_$(BUILD)
309 | WORKDIR_DLL = $(WINVER)_$(CPU)_DLL_$(BUILD)
310 | WORKDIR_LIB = $(WINVER)_$(CPU)_LIB_$(BUILD)
311 | WORKDIR_EXE = $(WINVER)_$(CPU)_EXE_$(BUILD)
312 | !ELSE
313 | WORKDIR = $(WINVER)_$(CPU)_$(BUILDIR_EXT)_$(BUILD)
314 | !ENDIF
315 | !ENDIF
316 |
317 | CLEANTARGET=if exist "$(WORKDIR)\$(NULL)" rd /s /q $(WORKDIR)
318 | MAKEWORKDIR=if not exist "$(WORKDIR)\$(NULL)" mkdir $(WORKDIR)
319 | MAKEINSTALL=if not exist "$(INSTALLLOC)\$(NULL)" mkdir $(INSTALLLOC)
320 |
321 | !IF DEFINED(JAVA_HOME) && "$(JAVA_HOME)" != ""
322 | JAVA_INCLUDES=-I "$(JAVA_HOME)\include" -I "$(JAVA_HOME)\include\win32"
323 | !ENDIF
324 |
325 | # Assembler Section
326 | !IF !DEFINED(ML) || "$(ML)" == ""
327 | !IF "$(CPU)" == "X86"
328 | ML = ml.exe
329 | AFLAGS = /coff /Zi /c
330 | !ELSEIF "$(CPU)" == "X64"
331 | ML = ml64.exe
332 | AFLAGS = /Zi /c
333 | !ELSEIF "$(CPU)" == "I64"
334 | ML = ml64.exe
335 | AFLAGS = /coff /Zi /c
336 | !ENDIF
337 | !ENDIF
338 |
339 |
--------------------------------------------------------------------------------
/native/NOTICE.bin.win:
--------------------------------------------------------------------------------
1 | Apache Tomcat Native Library
2 | Copyright 2002-2024 The Apache Software Foundation
3 |
4 | This product includes software developed at
5 | The Apache Software Foundation (http://www.apache.org/).
6 |
7 | This software contains code derived from netty-native
8 | developed by the Netty project
9 | (http://netty.io, https://github.com/netty/netty-tcnative/)
10 | and from finagle-native developed at Twitter
11 | (https://github.com/twitter/finagle).
12 |
13 | This product includes software developed by the OpenSSL Project
14 | for use in the OpenSSL Toolkit. (http://www.openssl.org/)
15 |
16 | This product includes cryptographic software written by
17 | Eric Young (eay@cryptsoft.com)
18 |
19 | This product includes software written by
20 | Tim Hudson (tjh@cryptsoft.com)
--------------------------------------------------------------------------------
/native/build.conf:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | #
19 | # Configuration file for APRJAVA. Used by APR/build/gen-build.py
20 | #
21 |
22 | [options]
23 |
24 | # the platform-independent .c files
25 | paths =
26 | src/*.c
27 |
28 | # we have no platform-specific subdirs
29 | platform_dirs =
30 | os
31 |
32 | # the public headers
33 | headers = include/*.h
34 |
35 | # we have a recursive makefile for the test files (for now)
36 | # test/*.c
37 |
--------------------------------------------------------------------------------
/native/build/PrintPath:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Licensed to the Apache Software Foundation (ASF) under one or more
4 | # contributor license agreements. See the NOTICE file distributed with
5 | # this work for additional information regarding copyright ownership.
6 | # The ASF licenses this file to You under the Apache License, Version 2.0
7 | # (the "License"); you may not use this file except in compliance with
8 | # the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | #
19 | # Look for program[s] somewhere in $PATH.
20 | #
21 | # Options:
22 | # -s
23 | # Do not print out full pathname. (silent)
24 | # -pPATHNAME
25 | # Look in PATHNAME instead of $PATH
26 | #
27 | # Usage:
28 | # PrintPath [-s] [-pPATHNAME] program [program ...]
29 | #
30 | # Initially written by Jim Jagielski for the Apache configuration mechanism
31 | # (with kudos to Kernighan/Pike)
32 |
33 | ##
34 | # Some "constants"
35 | ##
36 | pathname=$PATH
37 | echo="yes"
38 |
39 | ##
40 | # Find out what OS we are running for later on
41 | ##
42 | os=`(uname) 2>/dev/null`
43 |
44 | ##
45 | # Parse command line
46 | ##
47 | for args in $*
48 | do
49 | case $args in
50 | -s ) echo="no" ;;
51 | -p* ) pathname="`echo $args | sed 's/^..//'`" ;;
52 | * ) programs="$programs $args" ;;
53 | esac
54 | done
55 |
56 | ##
57 | # Now we make the adjustments required for OS/2 and everyone
58 | # else :)
59 | #
60 | # First of all, all OS/2 programs have the '.exe' extension.
61 | # Next, we adjust PATH (or what was given to us as PATH) to
62 | # be whitespace separated directories.
63 | # Finally, we try to determine the best flag to use for
64 | # test/[] to look for an executable file. OS/2 just has '-r'
65 | # but with other OSs, we do some funny stuff to check to see
66 | # if test/[] knows about -x, which is the prefered flag.
67 | ##
68 |
69 | if [ "x$os" = "xOS/2" ]
70 | then
71 | ext=".exe"
72 | pathname=`echo -E $pathname |
73 | sed 's/^;/.;/
74 | s/;;/;.;/g
75 | s/;$/;./
76 | s/;/ /g
77 | s/\\\\/\\//g' `
78 | test_exec_flag="-r"
79 | else
80 | ext="" # No default extensions
81 | pathname=`echo $pathname |
82 | sed 's/^:/.:/
83 | s/::/:.:/g
84 | s/:$/:./
85 | s/:/ /g' `
86 | # Here is how we test to see if test/[] can handle -x
87 | testfile="pp.t.$$"
88 |
89 | cat > $testfile </dev/null`; then
98 | test_exec_flag="-x"
99 | else
100 | test_exec_flag="-r"
101 | fi
102 | rm -f $testfile
103 | fi
104 |
105 | for program in $programs
106 | do
107 | for path in $pathname
108 | do
109 | if [ $test_exec_flag $path/${program}${ext} ] && \
110 | [ ! -d $path/${program}${ext} ]; then
111 | if [ "x$echo" = "xyes" ]; then
112 | echo $path/${program}${ext}
113 | fi
114 | exit 0
115 | fi
116 |
117 | # Next try without extension (if one was used above)
118 | if [ "x$ext" != "x" ]; then
119 | if [ $test_exec_flag $path/${program} ] && \
120 | [ ! -d $path/${program} ]; then
121 | if [ "x$echo" = "xyes" ]; then
122 | echo $path/${program}
123 | fi
124 | exit 0
125 | fi
126 | fi
127 | done
128 | done
129 | exit 1
130 |
131 |
--------------------------------------------------------------------------------
/native/build/buildcheck.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one or more
4 | # contributor license agreements. See the NOTICE file distributed with
5 | # this work for additional information regarding copyright ownership.
6 | # The ASF licenses this file to You under the Apache License, Version 2.0
7 | # (the "License"); you may not use this file except in compliance with
8 | # the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 |
18 |
19 | echo "buildconf: checking installation..."
20 |
21 | # any python
22 | python=${PYTHON-`build/PrintPath python3 python2 python`}
23 | if test -z "$python"; then
24 | echo "buildconf: python not found."
25 | echo " You need python installed"
26 | echo " to build Tomcat Native from SVN."
27 | exit 1
28 | else
29 | py_version=`$python -c 'import sys; print sys.version' 2>&1|sed 's/ .*//;q'`
30 | echo "buildconf: python version $py_version (ok)"
31 | fi
32 |
33 | # autoconf 2.68 or newer
34 | ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;q'`
35 | if test -z "$ac_version"; then
36 | echo "buildconf: autoconf not found."
37 | echo " You need autoconf version 2.68 or newer installed"
38 | echo " to build Tomcat Native from SVN."
39 | exit 1
40 | fi
41 | IFS=.; set $ac_version; IFS=' '
42 | if test "$1" = "2" -a "$2" -lt "68" || test "$1" -lt "2"; then
43 | echo "buildconf: autoconf version $ac_version found."
44 | echo " You need autoconf version 2.68 or newer installed"
45 | echo " to build Tomcat Native from SVN."
46 | exit 1
47 | else
48 | echo "buildconf: autoconf version $ac_version (ok)"
49 | fi
50 |
51 | # Sample libtool --version outputs:
52 | # ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11)
53 | # ltmain.sh (GNU libtool 1.1361 2004/01/02 23:10:52) 1.5a
54 | # output is multiline from 1.5 onwards
55 |
56 | # Require libtool 1.4 or newer
57 | libtool=`build/PrintPath glibtool libtool libtool15 libtool14`
58 | lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'`
59 | if test -z "$lt_pversion"; then
60 | echo "buildconf: libtool not found."
61 | echo " You need libtool version 1.4 or newer installed"
62 | echo " to build Tomcat Native from SVN."
63 | exit 1
64 | fi
65 | lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
66 | IFS=.; set $lt_version; IFS=' '
67 | lt_status="good"
68 | if test "$1" = "1"; then
69 | if test "$2" -lt "4"; then
70 | lt_status="bad"
71 | fi
72 | fi
73 | if test $lt_status = "good"; then
74 | echo "buildconf: libtool version $lt_pversion (ok)"
75 | exit 0
76 | fi
77 |
78 | echo "buildconf: libtool version $lt_pversion found."
79 | echo " You need libtool version 1.4 or newer installed"
80 | echo " to build Tomcat Native from SVN."
81 |
82 | exit 1
83 |
--------------------------------------------------------------------------------
/native/build/get-version.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one or more
4 | # contributor license agreements. See the NOTICE file distributed with
5 | # this work for additional information regarding copyright ownership.
6 | # The ASF licenses this file to You under the Apache License, Version 2.0
7 | # (the "License"); you may not use this file except in compliance with
8 | # the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 |
18 | #
19 | # extract version numbers from a header file
20 | #
21 | # USAGE: get-version.sh CMD VERSION_HEADER PREFIX
22 | # where CMD is one of: all, major, libtool
23 | # where PREFIX is the prefix to {MAJOR|MINOR|PATCH}_VERSION defines
24 | #
25 | # get-version.sh all returns a dotted version number
26 | # get-version.sh major returns just the major version number
27 | # get-version.sh libtool returns a version "libtool -version-info" format
28 | #
29 |
30 | if test $# != 3; then
31 | echo "USAGE: $0 CMD VERSION_HEADER PREFIX"
32 | echo " where CMD is one of: all, major, libtool"
33 | exit 1
34 | fi
35 |
36 | major_sed="/#define.*$3_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p"
37 | minor_sed="/#define.*$3_MINOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p"
38 | patch_sed="/#define.*$3_PATCH_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p"
39 | major="`sed -n $major_sed $2`"
40 | minor="`sed -n $minor_sed $2`"
41 | patch="`sed -n $patch_sed $2`"
42 |
43 | if test "$1" = "all"; then
44 | echo ${major}.${minor}.${patch}
45 | elif test "$1" = "major"; then
46 | echo ${major}
47 | elif test "$1" = "libtool"; then
48 | # Yes, ${minor}:${patch}:${minor} is correct due to libtool idiocy.
49 | echo ${minor}:${patch}:${minor}
50 | else
51 | echo "ERROR: unknown version CMD ($1)"
52 | exit 1
53 | fi
54 |
--------------------------------------------------------------------------------
/native/build/lineends.pl:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/perl
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one or more
4 | # contributor license agreements. See the NOTICE file distributed with
5 | # this work for additional information regarding copyright ownership.
6 | # The ASF licenses this file to You under the Apache License, Version 2.0
7 | # (the "License"); you may not use this file except in compliance with
8 | # the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 |
18 | #
19 | # Heuristically converts line endings to the current OS's preferred format
20 | #
21 | # All existing line endings must be identical (e.g. lf's only, or even
22 | # the accedental cr.cr.lf sequence.) If some lines end lf, and others as
23 | # cr.lf, the file is presumed binary. If the cr character appears anywhere
24 | # except prefixed to an lf, the file is presumed binary. If there is no
25 | # change in the resulting file size, or the file is binary, the conversion
26 | # is discarded.
27 | #
28 | # Todo: Handle NULL stdin characters gracefully.
29 | #
30 |
31 | use IO::File;
32 | use File::Find;
33 |
34 | # The ignore list is '-' separated, with this leading hyphen and
35 | # trailing hyphens in ever concatinated list below.
36 | $ignore = "-";
37 |
38 | # Image formats
39 | $ignore .= "gif-jpg-jpeg-png-ico-bmp-";
40 |
41 | # Archive formats
42 | $ignore .= "tar-gz-z-zip-jar-war-bz2-tgz-";
43 |
44 | # Many document formats
45 | $ignore .= "eps-psd-pdf-ai-";
46 |
47 | # Some encodings
48 | $ignore .= "ucs2-ucs4-";
49 |
50 | # Some binary objects
51 | $ignore .= "class-so-dll-exe-obj-a-o-lo-slo-sl-dylib-";
52 |
53 | # Some build env files
54 | $ignore .= "mcp-xdc-ncb-opt-pdb-ilk-sbr-";
55 |
56 | $preservedate = 1;
57 |
58 | $forceending = 0;
59 |
60 | $givenpaths = 0;
61 |
62 | $notnative = 0;
63 |
64 | while (defined @ARGV[0]) {
65 | if (@ARGV[0] eq '--touch') {
66 | $preservedate = 0;
67 | }
68 | elsif (@ARGV[0] eq '--nocr') {
69 | $notnative = -1;
70 | }
71 | elsif (@ARGV[0] eq '--cr') {
72 | $notnative = 1;
73 | }
74 | elsif (@ARGV[0] eq '--force') {
75 | $forceending = 1;
76 | }
77 | elsif (@ARGV[0] eq '--FORCE') {
78 | $forceending = 2;
79 | }
80 | elsif (@ARGV[0] =~ m/^-/) {
81 | die "What is " . @ARGV[0] . " supposed to mean?\n\n"
82 | . "Syntax:\t$0 [option()s] [path(s)]\n\n" . <<'OUTCH'
83 | Where: paths specifies the top level directory to convert (default of '.')
84 | options are;
85 |
86 | --cr keep/add one ^M
87 | --nocr remove ^M's
88 | --touch the datestamp (default: keeps date/attribs)
89 | --force mismatched corrections (unbalanced ^M's)
90 | --FORCE all files regardless of file name!
91 |
92 | OUTCH
93 | }
94 | else {
95 | find(\&totxt, @ARGV[0]);
96 | print "scanned " . @ARGV[0] . "\n";
97 | $givenpaths = 1;
98 | }
99 | shift @ARGV;
100 | }
101 |
102 | if (!$givenpaths) {
103 | find(\&totxt, '.');
104 | print "did .\n";
105 | }
106 |
107 | sub totxt {
108 | $oname = $_;
109 | $tname = '.#' . $_;
110 | if (!-f) {
111 | return;
112 | }
113 | @exts = split /\./;
114 | if ($forceending < 2) {
115 | while ($#exts && ($ext = pop(@exts))) {
116 | if ($ignore =~ m|-$ext-|i) {
117 | return;
118 | }
119 | }
120 | }
121 | @ostat = stat($oname);
122 | $srcfl = new IO::File $oname, "r" or die;
123 | $dstfl = new IO::File $tname, "w" or die;
124 | binmode $srcfl;
125 | if ($notnative) {
126 | binmode $dstfl;
127 | }
128 | undef $t;
129 | while (<$srcfl>) {
130 | if (s/(\r*)\n$/\n/) {
131 | $n = length $1;
132 | if (!defined $t) {
133 | $t = $n;
134 | }
135 | if (!$forceending && (($n != $t) || m/\r/)) {
136 | print "mismatch in " .$oname. ":" .$n. " expected " .$t. "\n";
137 | undef $t;
138 | last;
139 | }
140 | elsif ($notnative > 0) {
141 | s/\n$/\r\n/;
142 | }
143 | }
144 | print $dstfl $_;
145 | }
146 | if (defined $t && (tell $srcfl == tell $dstfl)) {
147 | undef $t;
148 | }
149 | undef $srcfl;
150 | undef $dstfl;
151 | if (defined $t) {
152 | unlink $oname or die;
153 | rename $tname, $oname or die;
154 | @anames = ($oname);
155 | if ($preservedate) {
156 | utime $ostat[9], $ostat[9], @anames;
157 | }
158 | chmod $ostat[2] & 07777, @anames;
159 | chown $ostat[5], $ostat[6], @anames;
160 | print "Converted file " . $oname . " to text in " . $File::Find::dir . "\n";
161 | }
162 | else {
163 | unlink $tname or die;
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/native/build/mkdir.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Licensed to the Apache Software Foundation (ASF) under one or more
5 | # contributor license agreements. See the NOTICE file distributed with
6 | # this work for additional information regarding copyright ownership.
7 | # The ASF licenses this file to You under the Apache License, Version 2.0
8 | # (the "License"); you may not use this file except in compliance with
9 | # the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | ##
21 | ## mkdir.sh -- make directory hierarchy
22 | ##
23 | ## Based on `mkinstalldirs' from Noah Friedman
24 | ## as of 1994-03-25, which was placed in the Public Domain.
25 | ## Cleaned up for Apache's Autoconf-style Interface (APACI)
26 | ## by Ralf S. Engelschall
27 | ##
28 |
29 |
30 | umask 022
31 | errstatus=0
32 | for file in ${1+"$@"} ; do
33 | set fnord `echo ":$file" |\
34 | sed -e 's/^:\//%/' -e 's/^://' -e 's/\// /g' -e 's/^%/\//'`
35 | shift
36 | pathcomp=
37 | for d in ${1+"$@"}; do
38 | pathcomp="$pathcomp$d"
39 | case "$pathcomp" in
40 | -* ) pathcomp=./$pathcomp ;;
41 | ?: ) pathcomp="$pathcomp/"
42 | continue ;;
43 | esac
44 | if test ! -d "$pathcomp"; then
45 | echo "mkdir $pathcomp" 1>&2
46 | mkdir "$pathcomp" || errstatus=$?
47 | fi
48 | pathcomp="$pathcomp/"
49 | done
50 | done
51 | exit $errstatus
52 |
53 |
--------------------------------------------------------------------------------
/native/build/rpm/tcnative.spec.in:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | %define tcnver 2
19 | %define aprmajor 1
20 | %define aprminor 7
21 |
22 | Summary: Tomcat Native Java library
23 | Name: tcnative
24 | Version: TCN_VERSION
25 | Release: TCN_RELEASE
26 | License: Apache Software License
27 | Group: System Environment/Libraries
28 | URL: http://apr.apache.org/
29 | Source0: %{name}-%{version}.tar.gz
30 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
31 | BuildPrereq: autoconf, libtool, doxygen, apr-devel >= %{aprmajor}.%{aprminor}.0, openssl >= 3.0.0
32 |
33 | %description
34 | The mission of the Tomcat Native Library (TCN) is to provide a
35 | free library of C data structures and routines. This library
36 | contains additional utility interfaces for Java.
37 |
38 | %package devel
39 | Group: Development/Libraries
40 | Summary: Tomcat Native development kit
41 | Requires: tcnative = %{version}-%{release}, apr-devel >= %{aprmajor}.%{aprminor}.0, openssl-devel >= 3.0.0
42 |
43 | %description devel
44 | The mission of the Tomcat Native Library (TCN) is to provide a
45 | free library of C data structures and routines. This library
46 | contains additional utility interfaces for Java.
47 |
48 | %prep
49 | %setup -q
50 |
51 | %build
52 | %configure --with-apr=%{_prefix} \
53 | --includedir=%{_includedir}/%{name}
54 | make %{?_smp_mflags} && make dox
55 |
56 | %check
57 | # Run non-interactive tests
58 | pushd test
59 | make %{?_smp_mflags} testall CFLAGS=-fno-strict-aliasing
60 | ./testall -v || exit 1
61 | popd
62 |
63 | %install
64 | rm -rf $RPM_BUILD_ROOT
65 | make install DESTDIR=$RPM_BUILD_ROOT
66 |
67 | # Documentation
68 | mv docs/dox/html html
69 |
70 | # Unpackaged files
71 | rm -f $RPM_BUILD_ROOT%{_libdir}/tcnative.exp
72 |
73 | %clean
74 | rm -rf $RPM_BUILD_ROOT
75 |
76 | %post -p /sbin/ldconfig
77 |
78 | %postun -p /sbin/ldconfig
79 |
80 | %files
81 | %defattr(-,root,root,-)
82 | %doc CHANGES LICENSE NOTICE
83 | %{_libdir}/libtcnative-%{tcnver}.so.*
84 |
85 | %files devel
86 | %defattr(-,root,root,-)
87 | %{_libdir}/libtcnative-%{tcnver}.*a
88 | %{_libdir}/libtcnative-%{tcnver}.so
89 | %{_includedir}/%{name}/*.h
90 | %doc --parents html
91 |
92 | %changelog
93 | * Tue Jun 30 2022 Mark Thomas 2.0.0-1
94 | - update for tcnative 2.0
95 | * Sat Oct 31 2015 Rainer Jung 1.2.0-1
96 | - update for tcnative 1.2
97 | * Tue Jun 22 2004 Mladen Turk 1.0.0-1
98 | - update to support v1.0.2 of APR
99 |
100 |
--------------------------------------------------------------------------------
/native/build/tcnative.m4:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | dnl
19 | dnl TCN_FIND_APR: figure out where APR is located
20 | dnl
21 | AC_DEFUN([TCN_FIND_APR],[
22 |
23 | dnl use the find_apr.m4 script to locate APR. sets apr_found and apr_config
24 | APR_FIND_APR(,,1,[1])
25 | if test "$apr_found" = "no"
26 | then
27 | AC_MSG_ERROR(APR could not be located. Please use the --with-apr option.)
28 | fi
29 |
30 | sapr_pversion="`$apr_config --version`"
31 | if test -z "$sapr_pversion"
32 | then
33 | AC_MSG_ERROR(APR config could not be located. Please use the --with-apr option.)
34 | fi
35 | sapr_version="`echo $sapr_pversion|sed -e 's/\([a-z]*\)$/.\1/'`"
36 | tc_save_IFS=$IFS
37 | IFS=.
38 | set $sapr_version
39 | IFS=$tc_save_IFS
40 | decimal_apr_version=`printf %02d%02d%03d ${1} ${2} ${3}`
41 | if test "${decimal_apr_version}" -lt "0107000"
42 | then
43 | AC_MSG_ERROR(Found APR $sapr_version. You need version 1.7.0 or newer installed.)
44 | fi
45 | AC_MSG_NOTICE(APR $sapr_version detected.)
46 |
47 | APR_BUILD_DIR="`$apr_config --installbuilddir`"
48 |
49 | dnl make APR_BUILD_DIR an absolute directory (we'll need it in the
50 | dnl sub-projects in some cases)
51 | APR_BUILD_DIR="`cd $APR_BUILD_DIR && pwd`"
52 |
53 | APR_INCLUDES="`$apr_config --includes`"
54 | APR_LIBTOOL_LIBS="`$apr_config --link-libtool --libs`"
55 | APR_LIBS="`$apr_config --link-ld --libs`"
56 | APR_SO_EXT="`$apr_config --apr-so-ext`"
57 | APR_LIB_TARGET="`$apr_config --apr-lib-target`"
58 |
59 | AC_SUBST(APR_INCLUDES)
60 | AC_SUBST(APR_LIBTOOL_LIBS)
61 | AC_SUBST(APR_LIBS)
62 | AC_SUBST(APR_BUILD_DIR)
63 | ])
64 |
65 | dnl --------------------------------------------------------------------------
66 | dnl TCN_JDK
67 | dnl
68 | dnl Detection of JDK location
69 | dnl Result goes in JAVA_HOME
70 | dnl
71 | dnl --------------------------------------------------------------------------
72 | AC_DEFUN([TCN_FIND_JAVA],[
73 | AC_ARG_WITH(java-home,[ --with-java-home=DIR Specify the location of your JDK installation],[
74 | AC_MSG_CHECKING([JAVA_HOME])
75 | if test -d "$withval"
76 | then
77 | JAVA_HOME="$withval"
78 | AC_MSG_RESULT([$JAVA_HOME])
79 | else
80 | AC_MSG_RESULT([failed])
81 | AC_MSG_ERROR([$withval is not a directory])
82 | fi
83 | AC_SUBST(JAVA_HOME)
84 | ])
85 | if test "x$JAVA_HOME" = x
86 | then
87 | AC_MSG_CHECKING([for JDK location])
88 | # Oh well, nobody set JAVA_HOME, have to guess
89 | # Check if we have java in the PATH.
90 | java_prog="`which java 2>/dev/null || true`"
91 | if test "x$java_prog" != x
92 | then
93 | java_bin="`dirname $java_prog`"
94 | java_top="`dirname $java_bin`"
95 | if test -f "$java_top/include/jni.h"
96 | then
97 | JAVA_HOME="$java_top"
98 | AC_MSG_RESULT([${java_top}])
99 | fi
100 | fi
101 | fi
102 | if test x"$JAVA_HOME" = x
103 | then
104 | AC_MSG_ERROR([Java Home not defined. Rerun with --with-java-home=[...] parameter])
105 | fi
106 | ])
107 |
108 | AC_DEFUN([TCN_FIND_JDK_OS],[
109 | tempval=""
110 | JAVA_OS=""
111 | AC_ARG_WITH(os-type,[ --with-os-type[=SUBDIR] Location of JDK os-type subdirectory.],
112 | [
113 | tempval=$withval
114 | if test ! -d "$JAVA_HOME/$tempval"
115 | then
116 | AC_MSG_ERROR(Not a directory: ${JAVA_HOME}/${tempval})
117 | fi
118 | JAVA_OS=$tempval
119 | ],
120 | [
121 | AC_MSG_CHECKING(for JDK os include directory)
122 | JAVA_OS=NONE
123 | if test -f $JAVA_HOME/$JAVA_INC/jni_md.h
124 | then
125 | JAVA_OS=""
126 | else
127 | for f in $JAVA_HOME/$JAVA_INC/*/jni_md.h
128 | do
129 | if test -f $f; then
130 | JAVA_OS=`dirname $f`
131 | JAVA_OS=`basename $JAVA_OS`
132 | echo " $JAVA_OS"
133 | break
134 | fi
135 | done
136 | if test "x$JAVA_OS" = "xNONE"; then
137 | AC_MSG_RESULT(Cannot find jni_md.h in ${JAVA_HOME}/${OS})
138 | AC_MSG_ERROR(You should retry --with-os-type=SUBDIR)
139 | fi
140 | fi
141 | ])
142 | ])
143 |
144 | dnl
145 | dnl TCN_FIND_SSL_TOOLKIT
146 | dnl
147 | dnl Configure for the detected openssl toolkit installation, giving
148 | dnl preference to "--with-ssl=" if it was specified.
149 | dnl
150 | AC_DEFUN([TCN_FIND_SSL_TOOLKIT],[
151 | AC_ARG_WITH(ssl,[ --with-ssl=DIR Specify the location of your OpenSSL installation],[
152 | AC_MSG_CHECKING([for OpenSSL library])
153 | if test -d "$withval"
154 | then
155 | use_openssl="$withval"
156 | AC_MSG_RESULT([$use_openssl])
157 | else
158 | AC_MSG_RESULT([failed])
159 | AC_MSG_ERROR([$withval is not a directory])
160 | fi
161 | ])
162 |
163 | if test "x$use_openssl" = x
164 | then
165 | # User did not specify a path - guess it
166 | AC_MSG_CHECKING([for OpenSSL location])
167 | openssldirs="/usr /usr/local /usr/local/ssl /usr/pkg /usr/sfw"
168 | for d in $openssldirs
169 | do
170 | if test -f $d/include/openssl/opensslv.h
171 | then
172 | use_openssl=$d
173 | break
174 | fi
175 | done
176 | fi
177 |
178 | if test x"$use_openssl" = x
179 | then
180 | AC_MSG_RESULT(not found)
181 | AC_MSG_ERROR([OpenSSL was not found in any of $openssldirs; use --with-ssl=/path])
182 | fi
183 |
184 | USE_OPENSSL='-DOPENSSL'
185 |
186 | test -d $use_openssl/lib64 && ssllibdir=lib64 || ssllibdir=lib
187 |
188 | if test "$use_openssl" = "/usr"
189 | then
190 | TCN_OPENSSL_INC=""
191 | TCN_OPENSSL_LIBS="-lssl -lcrypto"
192 | else
193 | TCN_OPENSSL_INC="-I$use_openssl/include"
194 | case $host in
195 | *-solaris*)
196 | TCN_OPENSSL_LIBS="-L$use_openssl/$ssllibdir -R$use_openssl/$ssllibdir -lssl -lcrypto"
197 | ;;
198 | *-hp-hpux*)
199 | # By default cc/aCC on HP-UX IA64 will produce 32 bit output
200 | ssllibdir=lib/hpux32
201 | TCN_OPENSSL_LIBS="-L$use_openssl/$ssllibdir -lssl -lcrypto"
202 | ;;
203 | *linux*|*freebsd*)
204 | TCN_OPENSSL_LIBS="-L$use_openssl/$ssllibdir -Wl,-rpath,$use_openssl/$ssllibdir -lssl -lcrypto"
205 | ;;
206 | *)
207 | TCN_OPENSSL_LIBS="-L$use_openssl/$ssllibdir -lssl -lcrypto"
208 | ;;
209 | esac
210 | fi
211 |
212 | AC_MSG_RESULT(using openssl from $use_openssl/$ssllibdir and $use_openssl/include)
213 |
214 | saved_cflags="$CFLAGS"
215 | saved_libs="$LIBS"
216 | CFLAGS="$CFLAGS $TCN_OPENSSL_INC"
217 | LIBS="$LIBS $TCN_OPENSSL_LIBS"
218 |
219 | AC_ARG_ENABLE(openssl-version-check,
220 | [AS_HELP_STRING([--disable-openssl-version-check],
221 | [disable the OpenSSL version check])])
222 | case "$enable_openssl_version_check" in
223 | yes|'')
224 | AC_MSG_CHECKING(OpenSSL library version >= 3.0.0)
225 | AC_RUN_IFELSE([AC_LANG_SOURCE([[
226 | #include
227 | #include
228 | int main() {
229 | #ifdef LIBRESSL_VERSION_NUMBER
230 | if (OPENSSL_VERSION_NUMBER >= 0x3000000fL || LIBRESSL_VERSION_NUMBER >= 0x3050200fL)
231 | #else
232 | if (OPENSSL_VERSION_NUMBER >= 0x3000000fL)
233 | #endif
234 | return (0);
235 | printf("\n\nFound OPENSSL_VERSION_NUMBER %#010x (" OPENSSL_VERSION_TEXT ")\n",
236 | OPENSSL_VERSION_NUMBER);
237 | printf("Require OPENSSL_VERSION_NUMBER 0x3000000f or greater (3.0.0)\n\n");
238 | return (1);
239 | }
240 | ]])],[AC_MSG_RESULT(ok)],[AC_MSG_ERROR(Your version of OpenSSL is not compatible with this version of tcnative)],[AC_MSG_RESULT(assuming target platform has compatible version)])
241 | ;;
242 | no)
243 | AC_MSG_RESULT(Skipped OpenSSL version check)
244 | ;;
245 | esac
246 |
247 | CFLAGS="$saved_cflags"
248 | LIBS="$saved_libs"
249 |
250 | APR_ADDTO(TCNATIVE_PRIV_INCLUDES, [$TCN_OPENSSL_INC])
251 | APR_ADDTO(TCNATIVE_LDFLAGS, [$TCN_OPENSSL_LIBS])
252 | ])
253 |
254 | dnl
255 | dnl TCN_FIND_APR_FEATURE: figure out if APR feature is suipported
256 | dnl
257 | AC_DEFUN([TCN_FIND_APR_FEATURE],[
258 | saved_cflags="$CFLAGS"
259 | saved_libs="$LIBS"
260 | CFLAGS="$CFLAGS $APR_INCLUDES"
261 | LIBS="$LIBS $APR_LIBS"
262 | chk_result=0
263 | AC_CHECK_LIB(apr-1, $1,[chk_result=1])
264 | CFLAGS="$saved_cflags"
265 | LIBS="$saved_libs"
266 | if test "$chk_result" != "0"
267 | then
268 | APR_ADDTO(CFLAGS, [-DHAVE_$2])
269 | fi
270 | ])
271 |
--------------------------------------------------------------------------------
/native/buildconf:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Licensed to the Apache Software Foundation (ASF) under one or more
4 | # contributor license agreements. See the NOTICE file distributed with
5 | # this work for additional information regarding copyright ownership.
6 | # The ASF licenses this file to You under the Apache License, Version 2.0
7 | # (the "License"); you may not use this file except in compliance with
8 | # the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | #
19 |
20 | # Default place to look for apr source. Can be overridden with
21 | # --with-apr=[directory]
22 | apr_src_dir=`pwd`/srclib/apr-1.5.2
23 |
24 | while [ $# -gt 0 ]
25 | do
26 | # Normalize
27 | case "$1" in
28 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
29 | *) optarg= ;;
30 | esac
31 |
32 | case "$1" in
33 | --with-apr=*)
34 | apr_src_dir=$optarg
35 | ;;
36 | esac
37 |
38 | shift
39 | done
40 |
41 | if [ -d "$apr_src_dir" ]; then
42 | echo ""
43 | echo "Looking for apr source in $apr_src_dir"
44 | else
45 | echo ""
46 | echo "Problem finding apr source in $apr_src_dir."
47 | echo "Use:"
48 | echo " --with-apr=[directory]"
49 | exit 1
50 | fi
51 |
52 | if [ ! -d "$apr_src_dir/build" ]; then
53 | echo "Directory '$apr_src_dir/build' missing - wrong apr source directory?"
54 | exit 1
55 | fi
56 |
57 | # Remove some files, then copy them from apr source tree
58 | for file in apr_common.m4 find_apr.m4 install.sh config.guess config.sub
59 | do
60 | if [ ! -f "$apr_src_dir/build/$file" ]; then
61 | echo "File '$apr_src_dir/build/$file' missing - wrong apr source directory?"
62 | exit 1
63 | fi
64 | rm -f build/$file
65 | cp $apr_src_dir/build/$file build/
66 | done
67 |
68 | # Remove aclocal.m4 as it'll break some builds...
69 | rm -rf aclocal.m4 autom4te*.cache
70 |
71 | echo "Creating configure ..."
72 | ### do some work to toss config.cache?
73 | ${AUTORECONF:-autoreconf} --install --force
74 | if [ $? -gt 0 ]; then
75 | echo "autoconf failed"
76 | exit 1
77 | fi
78 |
79 | #
80 | # Generate build-outputs.mk for the build systme
81 | #
82 | PYTHON=${PYTHON-`build/PrintPath python3 python2 python`}
83 |
84 | echo "Generating 'make' outputs ..."
85 | ${PYTHON} $apr_src_dir/build/gen-build.py make
86 | if [ $? -gt 0 ]; then
87 | echo "Creating build-outputs.mk failed"
88 | exit 1
89 | fi
90 |
91 | # Remove autoconf cache again
92 | rm -rf autom4te*.cache
93 |
94 | # Create RPM Spec file
95 | echo rebuilding rpm spec file
96 | REVISION=`build/get-version.sh all include/tcn_version.h TCN`
97 | # Strip everything behind "-"
98 | VERSION=`echo $REVISION | sed -e 's/-.*//'`
99 | # Strip everything before "-"
100 | RELEASE=`echo $REVISION | sed -e 's/.*-//'`
101 | # Handle case of no "-" in REVISION
102 | if [ "x$RELEASE" = "x$REVISION" ]; then
103 | RELEASE=1
104 | fi
105 | echo "Using version '$VERSION' and release '$RELEASE' in RPM spec file"
106 | sed -e "s/TCN_VERSION/$VERSION/" \
107 | -e "s/TCN_RELEASE/$RELEASE/" \
108 | ./build/rpm/tcnative.spec.in \
109 | > tcnative.spec
110 |
--------------------------------------------------------------------------------
/native/config.layout:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | ##
19 | ## config.layout -- Pre-defined Installation Path Layouts
20 | ##
21 | ## Hints:
22 | ## - layouts can be loaded with configure's --enable-layout=ID option
23 | ## - when no --enable-layout option is given, the default layout is `apr'
24 | ## - a trailing plus character (`+') on paths is replaced with a
25 | ## `/' suffix where is currently hardcoded to 'apr'.
26 | ## (This may become a configurable parameter at some point.)
27 | ##
28 |
29 | # Generic path layout that needs --prefix=/some/path
30 |
31 | exec_prefix: ${prefix}
32 | bindir: ${exec_prefix}/bin
33 | sbindir: ${exec_prefix}/bin
34 | libdir: ${exec_prefix}/lib
35 | libexecdir: ${exec_prefix}/modules
36 | mandir: ${prefix}/man
37 | sysconfdir: ${prefix}/conf
38 | datadir: ${prefix}
39 | installbuilddir: ${datadir}/build
40 | includedir: ${prefix}/include/tomcat-native-${TCNATIVE_MAJOR_VERSION}
41 | localstatedir: ${prefix}
42 | libsuffix: -${TCNATIVE_MAJOR_VERSION}
43 |
44 |
45 | # Classical Tomcat Native path layout designed for parallel installs.
46 |
47 | prefix: /usr/local/apr
48 | exec_prefix: ${prefix}
49 | bindir: ${exec_prefix}/bin
50 | sbindir: ${exec_prefix}/bin
51 | libdir: ${exec_prefix}/lib
52 | libexecdir: ${exec_prefix}/modules
53 | mandir: ${prefix}/man
54 | sysconfdir: ${prefix}/conf
55 | datadir: ${prefix}
56 | installbuilddir: ${datadir}/build
57 | includedir: ${prefix}/include
58 | localstatedir: ${prefix}
59 | libsuffix: -${TCNATIVE_MAJOR_VERSION}
60 |
61 |
62 | # Classical single-installation APR path layout.
63 |
64 | prefix: /usr/local/apr
65 | exec_prefix: ${prefix}
66 | bindir: ${exec_prefix}/bin
67 | sbindir: ${exec_prefix}/bin
68 | libdir: ${exec_prefix}/lib
69 | libexecdir: ${exec_prefix}/modules
70 | mandir: ${prefix}/man
71 | sysconfdir: ${prefix}/conf
72 | datadir: ${prefix}
73 | installbuilddir: ${datadir}/build
74 | includedir: ${prefix}/include
75 | localstatedir: ${prefix}
76 |
77 |
78 | # GNU standards conforming path layout.
79 | # See FSF's GNU project `make-stds' document for details.
80 |
81 | prefix: /usr/local
82 | exec_prefix: ${prefix}
83 | bindir: ${exec_prefix}/bin
84 | sbindir: ${exec_prefix}/sbin
85 | libdir: ${exec_prefix}/lib
86 | libexecdir: ${exec_prefix}/libexec
87 | mandir: ${prefix}/man
88 | sysconfdir: ${prefix}/etc+
89 | datadir: ${prefix}/share+
90 | installbuilddir: ${datadir}/build
91 | includedir: ${prefix}/include+
92 | localstatedir: ${prefix}/var+
93 | runtimedir: ${localstatedir}/run
94 |
95 |
96 | # Mac OS X Server (Rhapsody)
97 |
98 | prefix: /Local/Library/WebServer
99 | exec_prefix: /usr
100 | bindir: ${exec_prefix}/bin
101 | sbindir: ${exec_prefix}/sbin
102 | libdir: ${exec_prefix}/lib
103 | libexecdir: /System/Library/apr/Modules
104 | mandir: ${exec_prefix}/share/man
105 | sysconfdir: ${prefix}/Configuration
106 | datadir: ${prefix}
107 | installbuilddir: /System/Library/apr/Build
108 | includedir: /System/Library/Frameworks/apr.framework/Versions/2.0/Headers
109 | localstatedir: /var
110 | runtimedir: ${prefix}/Logs
111 |
112 |
113 | # Darwin/Mac OS Layout
114 |
115 | prefix: /usr
116 | exec_prefix: ${prefix}
117 | bindir: ${exec_prefix}/bin
118 | sbindir: ${exec_prefix}/sbin
119 | libdir: ${exec_prefix}/lib
120 | libexecdir: ${exec_prefix}/libexec+
121 | mandir: ${prefix}/share/man
122 | datadir: /Library/WebServer
123 | sysconfdir: /etc+
124 | installbuilddir: ${prefix}/share/httpd/build
125 | includedir: ${prefix}/include+
126 | localstatedir: /var
127 | runtimedir: ${localstatedir}/run
128 |
129 |
130 | # Red Hat Linux 7.x layout
131 |
132 | prefix: /usr
133 | exec_prefix: ${prefix}
134 | bindir: ${prefix}/bin
135 | sbindir: ${prefix}/sbin
136 | libdir: ${prefix}/lib
137 | libexecdir: ${prefix}/lib/apr
138 | mandir: ${prefix}/man
139 | sysconfdir: /etc/httpd/conf
140 | datadir: /var/www
141 | installbuilddir: ${datadir}/build
142 | includedir: ${prefix}/include/tomcat-native
143 | localstatedir: /var
144 | runtimedir: ${localstatedir}/run
145 |
146 |
147 | # According to the /opt filesystem conventions
148 |
149 | prefix: /opt/apr
150 | exec_prefix: ${prefix}
151 | bindir: ${exec_prefix}/bin
152 | sbindir: ${exec_prefix}/sbin
153 | libdir: ${exec_prefix}/lib
154 | libexecdir: ${exec_prefix}/libexec
155 | mandir: ${prefix}/man
156 | sysconfdir: /etc${prefix}
157 | datadir: ${prefix}/share
158 | installbuilddir: ${datadir}/build
159 | includedir: ${prefix}/include
160 | localstatedir: /var${prefix}
161 | runtimedir: ${localstatedir}/run
162 |
163 |
164 | # BeOS layout...
165 |
166 | prefix: /boot/home/apr
167 | exec_prefix: ${prefix}
168 | bindir: ${exec_prefix}/bin
169 | sbindir: ${exec_prefix}/bin
170 | libdir: ${exec_prefix}/lib
171 | libexecdir: ${exec_prefix}/libexec
172 | mandir: ${prefix}/man
173 | sysconfdir: ${prefix}/conf
174 | datadir: ${prefix}
175 | installbuilddir: ${datadir}/build
176 | includedir: ${prefix}/include
177 | localstatedir: ${prefix}
178 | runtimedir: ${localstatedir}/logs
179 |
180 |
181 | # SuSE 6.x layout
182 |
183 | prefix: /usr
184 | exec_prefix: ${prefix}
185 | bindir: ${prefix}/bin
186 | sbindir: ${prefix}/sbin
187 | libdir: ${prefix}/lib
188 | libexecdir: ${prefix}/lib/apr
189 | mandir: ${prefix}/share/man
190 | sysconfdir: /etc/httpd
191 | datadir: /usr/local/httpd
192 | installbuilddir: ${datadir}/build
193 | includedir: ${prefix}/include/tomcat-native
194 | localstatedir: /var/lib/httpd
195 | runtimedir: /var/run
196 |
197 |
198 | # BSD/OS layout
199 |
200 | prefix: /var/www
201 | exec_prefix: /usr/contrib
202 | bindir: ${exec_prefix}/bin
203 | sbindir: ${exec_prefix}/bin
204 | libdir: ${exec_prefix}/lib
205 | libexecdir: ${exec_prefix}/libexec/apr
206 | mandir: ${exec_prefix}/man
207 | sysconfdir: ${prefix}/conf
208 | datadir: ${prefix}
209 | installbuilddir: ${datadir}/build
210 | includedir: ${exec_prefix}/include/tomcat-native
211 | localstatedir: /var
212 | runtimedir: ${localstatedir}/run
213 |
214 |
215 | # Solaris 8 Layout
216 |
217 | prefix: /usr/apr
218 | exec_prefix: ${prefix}
219 | bindir: ${exec_prefix}/bin
220 | sbindir: ${exec_prefix}/bin
221 | libdir: ${exec_prefix}/lib
222 | libexecdir: ${exec_prefix}/libexec
223 | mandir: ${exec_prefix}/man
224 | sysconfdir: /etc/apr
225 | datadir: /var/apr
226 | installbuilddir: ${datadir}/build
227 | includedir: ${exec_prefix}/include
228 | localstatedir: ${prefix}
229 | runtimedir: /var/run
230 |
231 |
232 | # OpenBSD Layout
233 |
234 | prefix: /var/www
235 | exec_prefix: /usr
236 | bindir: ${exec_prefix}/bin
237 | sbindir: ${exec_prefix}/sbin
238 | libdir: ${exec_prefix}/lib
239 | libexecdir: ${exec_prefix}/lib/apr/modules
240 | mandir: ${exec_prefix}/share/man
241 | sysconfdir: ${prefix}/conf
242 | datadir: ${prefix}
243 | installbuilddir: ${prefix}/build
244 | includedir: ${exec_prefix}/lib/tomcat-native/include
245 | localstatedir: ${prefix}
246 | runtimedir: ${prefix}/logs
247 |
248 |
249 | # Debian layout
250 |
251 | prefix:
252 | exec_prefix: ${prefix}/usr
253 | bindir: ${exec_prefix}/bin
254 | sbindir: ${exec_prefix}/sbin
255 | libdir: ${exec_prefix}/lib
256 | libexecdir: ${exec_prefix}/lib/apr/modules
257 | mandir: ${exec_prefix}/share/man
258 | datadir: ${exec_prefix}/share/apr
259 | includedir: ${exec_prefix}/include/tomcat-native-${TCNATIVE_MAJOR_VERSION}
260 | localstatedir: ${prefix}/var/run
261 | runtimedir: ${prefix}/var/run
262 | infodir: ${exec_prefix}/share/info
263 | libsuffix -${TCNATIVE_MAJOR_VERSION}
264 | installbuilddir: ${prefix}/usr/share/apache2/build
265 |
266 |
--------------------------------------------------------------------------------
/native/configure.ac:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | dnl
19 | dnl Process this file with autoconf to produce a configure script
20 | dnl
21 |
22 | AC_PREREQ(2.68)
23 | AC_INIT(configure.ac)
24 |
25 | AC_CONFIG_AUX_DIR(build)
26 |
27 | sinclude(build/apr_common.m4)
28 | sinclude(build/tcnative.m4)
29 | sinclude(build/find_apr.m4)
30 |
31 | dnl Generate ./config.nice for reproducing runs of configure
32 | dnl
33 | APR_CONFIG_NICE(config.nice)
34 |
35 | dnl # Some initial steps for configuration. We setup the default directory
36 | dnl # and which files are to be configured.
37 |
38 | dnl Absolute source/build directory
39 | abs_srcdir=`(cd $srcdir && pwd)`
40 | abs_builddir=`pwd`
41 |
42 | if test "$abs_builddir" != "$abs_srcdir"; then
43 | USE_VPATH=1
44 | TCN_CONFIG_LOCATION=build
45 | else
46 | TCN_CONFIG_LOCATION=source
47 | fi
48 |
49 | AC_SUBST(TCN_CONFIG_LOCATION)
50 | AC_CANONICAL_TARGET
51 | AC_PROG_INSTALL
52 |
53 | dnl Generate the libtool script which is needed for rlibtool
54 | LT_INIT
55 |
56 | dnl
57 | dnl compute the top directory of the build
58 | dnl note: this is needed for LIBTOOL and exporting the bundled Expat
59 | dnl
60 | top_builddir="$abs_builddir"
61 | AC_SUBST(top_builddir)
62 | AC_SUBST(abs_srcdir)
63 | AC_SUBST(abs_builddir)
64 |
65 | dnl Initialize mkdir -p functionality.
66 | APR_MKDIR_P_CHECK($abs_srcdir/build/mkdir.sh)
67 |
68 | dnl get our version information
69 | get_version="$abs_srcdir/build/get-version.sh"
70 | version_hdr="$abs_srcdir/include/tcn_version.h"
71 | TCNATIVE_MAJOR_VERSION="`$get_version major $version_hdr TCN`"
72 | TCNATIVE_DOTTED_VERSION="`$get_version all $version_hdr TCN`"
73 | TCNATIVE_LIBTOOL_VERSION="`$get_version libtool $version_hdr TCN`"
74 |
75 | AC_SUBST(TCNATIVE_DOTTED_VERSION)
76 | AC_SUBST(TCNATIVE_MAJOR_VERSION)
77 | AC_SUBST(TCNATIVE_LIBTOOL_VERSION)
78 |
79 | echo "Tomcat Native Version: ${TCNATIVE_DOTTED_VERSION}"
80 |
81 | dnl Enable the layout handling code, then reparse the prefix-style
82 | dnl arguments due to autoconf being a PITA.
83 | APR_ENABLE_LAYOUT(tcnative)
84 | APR_PARSE_ARGUMENTS
85 |
86 | dnl
87 | dnl set up the compilation flags and stuff
88 | dnl
89 |
90 | TCNATIVE_INCLUDES=""
91 | TCNATIVE_PRIV_INCLUDES="-I$srcdir/include"
92 |
93 | dnl
94 | dnl Find the APR includes directory and (possibly) the source (base) dir.
95 | dnl
96 | TCN_FIND_APR
97 |
98 | dnl
99 | dnl even though we use apr_rules.mk for building apr-util, we need
100 | dnl to grab CC and CPP ahead of time so that apr-util config tests
101 | dnl use the same compiler as APR; we need the same compiler options
102 | dnl and feature test macros as well
103 | dnl
104 | APR_SETIFNULL(CC, `$apr_config --cc`)
105 | APR_SETIFNULL(CPP, `$apr_config --cpp`)
106 |
107 | AC_PROG_INSTALL
108 |
109 | dnl
110 | dnl Find the JVM related information
111 | dnl
112 | NEED_JNI_MD=yes
113 | TCN_FIND_JAVA
114 |
115 | dnl MAC OS X does not used include but Headers
116 | if test -d ${JAVA_HOME}/Headers; then
117 | JAVA_INC=Headers
118 | else
119 | JAVA_INC=include
120 | fi
121 | APR_ADDTO(TCNATIVE_PRIV_INCLUDES,[-I$JAVA_HOME/$JAVA_INC])
122 |
123 | dnl sableVM does not have/need $JAVA_OS/jni_md.h
124 | if test "$NEED_JNI_MD" = "yes"; then
125 | TCN_FIND_JDK_OS
126 | if test -z "${JAVA_OS}"; then
127 | AC_MSG_RESULT([jni_md.h found in $JAVA_HOME/$JAVA_INC])
128 | else
129 | APR_ADDTO(TCNATIVE_PRIV_INCLUDES,[-I$JAVA_HOME/$JAVA_INC/$JAVA_OS])
130 | fi
131 | fi
132 |
133 | AC_SUBST(JAVA_HOME)
134 | AC_SUBST(JAVA_OS)
135 |
136 |
137 | AC_ARG_ENABLE(insecure-export-ciphers,
138 | [AS_HELP_STRING([--enable-insecure-export-ciphers],[allow including insecure export and null ciphers in the cipher string (default is disabled=not allowed)])],
139 | [
140 | case "${enableval}" in
141 | yes )
142 | APR_ADDTO(CFLAGS, [-DHAVE_EXPORT_CIPHERS])
143 | AC_MSG_WARN([Enabling insecure export and null cipher support])
144 | ;;
145 | esac
146 | ])
147 |
148 | dnl
149 | dnl Find the OpenSSL installation
150 | dnl
151 | TCN_FIND_SSL_TOOLKIT
152 |
153 | so_ext=$APR_SO_EXT
154 | lib_target=$APR_LIB_TARGET
155 | AC_SUBST(so_ext)
156 | AC_SUBST(lib_target)
157 |
158 | TCNATIVE_LIBNAME="tcnative${libsuffix}"
159 | AC_SUBST(TCNATIVE_LIBNAME)
160 |
161 | EXTRA_OS_LINK=""
162 | host_alias=`uname -s`
163 | case "$host_alias" in
164 | dnl ### BeOS requires that ALL symbols resolve at LINK time!
165 | dnl ###
166 | dnl ### So, if we're building on BeOS then we need to add in the
167 | dnl ### apr and expat libraries to the build or it'll die a truly horrible
168 | dnl ### death. We now use the apr-config tool to determine the correct
169 | dnl ### library to link against :)
170 | *AIX*|*Darwin*|*BeOS*)
171 | dnl need such stuff as -liconv to be specified when building libaprutil.la
172 | EXTRA_OS_LINK='$(TCNATIVE_LDFLAGS) $(TCNATIVE_LIBS)'
173 | ;;
174 | *)
175 | ;;
176 | esac
177 |
178 | AC_SUBST(EXTRA_OS_LINK)
179 |
180 | dnl CFLAGS for maintainer mode
181 | dnl it also allows the CFLAGS environment variable.
182 | CFLAGS="${CFLAGS}"
183 | AC_ARG_ENABLE(maintainer-mode,
184 | [AS_HELP_STRING([--enable-maintainer-mode],[Turn on debugging and compile time warnings])],
185 | [
186 | case "${enableval}" in
187 | yes )
188 | if test "$GCC" = "yes"; then
189 | CFLAGS="${CFLAGS} -DDEBUG -Wall"
190 | else
191 | CFLAGS="${CFLAGS} -DDEBUG"
192 | fi
193 | AC_MSG_RESULT([...Enabling Maintainer mode...])
194 | ;;
195 | esac
196 | ])
197 |
198 | dnl
199 | dnl Prep all the flags and stuff for compilation and export to other builds
200 | dnl
201 | APR_ADDTO(TCNATIVE_LIBS, [$LIBS])
202 | APR_ADDTO(TCNATIVE_LIBS, [$APR_LIBTOOL_LIBS])
203 | APR_ADDTO(TCNATIVE_LDFLAGS, [$LDFLAGS])
204 |
205 | # Link libkstat for Solaris
206 | case $host in
207 | *-solaris2*)
208 | APR_ADDTO(TCNATIVE_LIBS, -lkstat)
209 | ;;
210 | *linux*)
211 | APR_ADDTO(CFLAGS, -DTCNATIVE_LINUX)
212 | ;;
213 | *)
214 | ;;
215 | esac
216 |
217 | TCN_FIND_APR_FEATURE([apr_pollset_wakeup],[POLLSET_WAKEUP])
218 |
219 | AC_SUBST(TCNATIVE_EXPORT_LIBS)
220 | AC_SUBST(TCNATIVE_PRIV_INCLUDES)
221 | AC_SUBST(TCNATIVE_INCLUDES)
222 | AC_SUBST(TCNATIVE_LDFLAGS)
223 | AC_SUBST(TCNATIVE_LIBS)
224 | AC_SUBST(CFLAGS)
225 | AC_SUBST(CPPFLAGS)
226 |
227 | dnl copy apr's rules.mk into our build directory.
228 | if test ! -d ./build; then
229 | $mkdir_p build
230 | fi
231 | cp $APR_BUILD_DIR/apr_rules.mk $abs_builddir/build/rules.mk
232 |
233 |
234 | dnl
235 | dnl BSD/OS (BSDi) needs to use a different include syntax in the Makefiles
236 | dnl
237 | case "$host_alias" in
238 | *bsdi* | BSD/OS)
239 | # Check whether they've installed GNU make
240 | if make --version > /dev/null 2>&1; then
241 | INCLUDE_RULES="include $abs_builddir/build/rules.mk"
242 | INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
243 | else
244 | INCLUDE_RULES=".include \"$abs_builddir/build/rules.mk\""
245 | INCLUDE_OUTPUTS=".include \"$abs_srcdir/build-outputs.mk\""
246 | fi
247 | ;;
248 | *)
249 | INCLUDE_RULES="include $abs_builddir/build/rules.mk"
250 | INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk"
251 | ;;
252 | esac
253 |
254 | AC_SUBST(INCLUDE_RULES)
255 | AC_SUBST(INCLUDE_OUTPUTS)
256 |
257 | if test -d $srcdir/test; then
258 | test_Makefile="test/Makefile"
259 | fi
260 |
261 | dnl
262 | dnl everything is done.
263 | MAKEFILES="Makefile"
264 | AC_CONFIG_FILES([
265 | $MAKEFILES
266 | ])
267 | AC_CONFIG_COMMANDS([default],[
268 | TCNATIVE_MAJOR_VERSION=$TCNATIVE_MAJOR_VERSION
269 | ],[])
270 | AC_OUTPUT
271 |
--------------------------------------------------------------------------------
/native/download_deps.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Small script to get a recent openssl
4 | # Will run configure and build_libs to generate the .s files
5 |
6 | cd $(dirname $0)
7 |
8 | SSL=openssl-3.0.14.tar.gz
9 | APR=apr-1.7.4.tar.gz
10 | mkdir -p deps
11 |
12 | if [ ! -f deps/$SSL ] ; then
13 | curl https://www.openssl.org/source/$SSL -o deps/$SSL
14 | fi
15 | if [ ! -d deps/src/openssl ] ; then
16 | mkdir -p deps/src/openssl
17 | (cd deps/src/openssl; tar -xvz --strip-components=1 -f ../../$SSL)
18 | fi
19 | if [ ! -f deps/src/openssl/Makefile ] ; then
20 | (cd deps/src/openssl; ./config )
21 | fi
22 |
23 | (cd deps/src/openssl; make build_libs )
24 |
25 | if [ ! -f deps/$APR ] ; then
26 | curl https://archive.apache.org/dist/apr/$APR -o deps/$APR
27 | fi
28 | if [ ! -d deps/src/apr ] ; then
29 | mkdir -p deps/src/apr
30 | (cd deps/src/apr; tar -xvz --strip-components=1 -f ../../$APR)
31 | fi
32 |
--------------------------------------------------------------------------------
/native/include/tcn.h:
--------------------------------------------------------------------------------
1 | /* Licensed to the Apache Software Foundation (ASF) under one or more
2 | * contributor license agreements. See the NOTICE file distributed with
3 | * this work for additional information regarding copyright ownership.
4 | * The ASF licenses this file to You under the Apache License, Version 2.0
5 | * (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef TCN_H
18 | #define TCN_H
19 |
20 | #include "apr.h"
21 | #include "apr_general.h"
22 | #include "apr_lib.h"
23 | #include "apr_pools.h"
24 | #include "apr_portable.h"
25 | #include "apr_network_io.h"
26 | #include "apr_poll.h"
27 | #include "apr_ring.h"
28 | #include "apr_strings.h"
29 |
30 | #if !APR_HAS_THREADS
31 | #error "Missing threading support from APR."
32 | #endif
33 |
34 | #if defined(DEBUG) || defined(_DEBUG)
35 | #endif
36 | #include
37 | #include
38 | #if defined(_WIN32) && !defined(__CYGWIN__)
39 | #include
40 | #else
41 | #include
42 | #endif
43 |
44 | #include "tcn_api.h"
45 |
46 |
47 | #if defined(_DEBUG) || defined(DEBUG)
48 | #include
49 | #define TCN_ASSERT(x) assert((x))
50 | #else
51 | #define TCN_ASSERT(x) (void)0
52 | #endif
53 |
54 | #ifndef APR_MAX_IOVEC_SIZE
55 | #define APR_MAX_IOVEC_SIZE 1024
56 | #endif
57 |
58 | #define TCN_TIMEUP APR_OS_START_USERERR + 1
59 | #define TCN_EAGAIN APR_OS_START_USERERR + 2
60 | #define TCN_EINTR APR_OS_START_USERERR + 3
61 | #define TCN_EINPROGRESS APR_OS_START_USERERR + 4
62 | #define TCN_ETIMEDOUT APR_OS_START_USERERR + 5
63 |
64 | #define TCN_LOG_EMERG 1
65 | #define TCN_LOG_ERROR 2
66 | #define TCN_LOG_NOTICE 3
67 | #define TCN_LOG_WARN 4
68 | #define TCN_LOG_INFO 5
69 | #define TCN_LOG_DEBUG 6
70 |
71 | #define TCN_ERROR_WRAP(E) \
72 | if (APR_STATUS_IS_TIMEUP(E)) \
73 | (E) = TCN_TIMEUP; \
74 | else if (APR_STATUS_IS_EAGAIN(E)) \
75 | (E) = TCN_EAGAIN; \
76 | else if (APR_STATUS_IS_EINTR(E)) \
77 | (E) = TCN_EINTR; \
78 | else if (APR_STATUS_IS_EINPROGRESS(E)) \
79 | (E) = TCN_EINPROGRESS; \
80 | else if (APR_STATUS_IS_ETIMEDOUT(E)) \
81 | (E) = TCN_ETIMEDOUT; \
82 | else \
83 | (E) = (E)
84 |
85 | #define TCN_CLASS_PATH "org/apache/tomcat/jni/"
86 | #define TCN_FINFO_CLASS TCN_CLASS_PATH "FileInfo"
87 | #define TCN_AINFO_CLASS TCN_CLASS_PATH "Sockaddr"
88 | #define TCN_ERROR_CLASS TCN_CLASS_PATH "Error"
89 | #define TCN_PARENT_IDE "TCN_PARENT_ID"
90 |
91 | #define UNREFERENCED(P) (P) = (P)
92 | #define UNREFERENCED_STDARGS e = e; o = o
93 | #ifdef WIN32
94 | #define LLT(X) (X)
95 | #else
96 | #define LLT(X) ((long)(X))
97 | #endif
98 | #define P2J(P) ((jlong)LLT(P))
99 | #define J2P(P, T) ((T)LLT((jlong)P))
100 | /* On stack buffer size */
101 | #define TCN_BUFFER_SZ 8192
102 | #define TCN_STDARGS JNIEnv *e, jobject o
103 | #define TCN_IMPARGS JNIEnv *e, jobject o, void *sock
104 | #define TCN_IMPCALL(X) e, o, X->opaque
105 |
106 | #define TCN_IMPLEMENT_CALL(RT, CL, FN) \
107 | JNIEXPORT RT JNICALL Java_org_apache_tomcat_jni_##CL##_##FN
108 |
109 | #define TCN_IMPLEMENT_METHOD(RT, FN) \
110 | static RT method_##FN
111 |
112 | #define TCN_GETNET_METHOD(FN) method_##FN
113 |
114 | #define TCN_SOCKET_UNKNOWN 0
115 | #define TCN_SOCKET_APR 1
116 | #define TCN_SOCKET_SSL 2
117 | #define TCN_SOCKET_UNIX 3
118 | #define TCN_SOCKET_NTPIPE 4
119 |
120 | #define TCN_SOCKET_GET_POOL 0
121 | #define TCN_SOCKET_GET_IMPL 1
122 | #define TCN_SOCKET_GET_APRS 2
123 | #define TCN_SOCKET_GET_TYPE 3
124 |
125 | typedef struct {
126 | int type;
127 | apr_status_t (*cleanup)(void *);
128 | apr_status_t (APR_THREAD_FUNC *close) (apr_socket_t *);
129 | apr_status_t (APR_THREAD_FUNC *shutdown) (apr_socket_t *, apr_shutdown_how_e);
130 | apr_status_t (APR_THREAD_FUNC *opt_get)(apr_socket_t *, apr_int32_t, apr_int32_t *);
131 | apr_status_t (APR_THREAD_FUNC *opt_set)(apr_socket_t *, apr_int32_t, apr_int32_t);
132 | apr_status_t (APR_THREAD_FUNC *timeout_get)(apr_socket_t *, apr_interval_time_t *);
133 | apr_status_t (APR_THREAD_FUNC *timeout_set)(apr_socket_t *, apr_interval_time_t);
134 | apr_status_t (APR_THREAD_FUNC *send) (apr_socket_t *, const char *, apr_size_t *);
135 | apr_status_t (APR_THREAD_FUNC *sendv)(apr_socket_t *, const struct iovec *, apr_int32_t, apr_size_t *);
136 | apr_status_t (APR_THREAD_FUNC *recv) (apr_socket_t *, char *, apr_size_t *);
137 | } tcn_nlayer_t;
138 |
139 | typedef struct tcn_socket_t tcn_socket_t;
140 | typedef struct tcn_pfde_t tcn_pfde_t;
141 |
142 | struct tcn_pfde_t {
143 | APR_RING_ENTRY(tcn_pfde_t) link;
144 | apr_pollfd_t fd;
145 | };
146 |
147 | struct tcn_socket_t {
148 | apr_pool_t *pool;
149 | apr_pool_t *child;
150 | apr_socket_t *sock;
151 | void *opaque;
152 | char *jsbbuff;
153 | char *jrbbuff;
154 | tcn_nlayer_t *net;
155 | tcn_pfde_t *pe;
156 | apr_time_t last_active;
157 | apr_interval_time_t timeout;
158 | };
159 |
160 | /* Private helper functions */
161 | void tcn_Throw(JNIEnv *, const char *, ...);
162 | void tcn_ThrowException(JNIEnv *, const char *);
163 | void tcn_ThrowMemoryException(JNIEnv *, const char *, int, const char *);
164 | void tcn_ThrowAPRException(JNIEnv *, apr_status_t);
165 | jstring tcn_new_string(JNIEnv *, const char *);
166 | jstring tcn_new_stringn(JNIEnv *, const char *, size_t);
167 | jbyteArray tcn_new_arrayb(JNIEnv *, const unsigned char *, size_t);
168 | jobjectArray tcn_new_arrays(JNIEnv *env, size_t len);
169 | char *tcn_get_string(JNIEnv *, jstring);
170 | char *tcn_strdup(JNIEnv *, jstring);
171 | char *tcn_pstrdup(JNIEnv *, jstring, apr_pool_t *);
172 | apr_status_t tcn_load_finfo_class(JNIEnv *, jclass);
173 | apr_status_t tcn_load_ainfo_class(JNIEnv *, jclass);
174 | unsigned long tcn_get_thread_id(void);
175 |
176 | #define J2S(V) c##V
177 | #define J2L(V) p##V
178 |
179 | #define J2T(T) (apr_time_t)((T))
180 |
181 | #define TCN_BEGIN_MACRO if (1) {
182 | #define TCN_END_MACRO } else (void)(0)
183 |
184 | #define TCN_ALLOC_CSTRING(V) \
185 | const char *c##V = V ? (const char *)((*e)->GetStringUTFChars(e, V, 0)) : NULL
186 |
187 | #define TCN_FREE_CSTRING(V) \
188 | if (c##V) (*e)->ReleaseStringUTFChars(e, V, c##V)
189 |
190 | #define TCN_ALLOC_JSTRING(V) \
191 | char *c##V = tcn_get_string(e, (V))
192 |
193 | #define AJP_TO_JSTRING(V) (*e)->NewStringUTF((e), (V))
194 |
195 | #define TCN_FREE_JSTRING(V) \
196 | TCN_BEGIN_MACRO \
197 | if (c##V) \
198 | free(c##V); \
199 | TCN_END_MACRO
200 |
201 | #define TCN_CHECK_ALLOCATED(x) \
202 | if (x == NULL) { \
203 | tcn_ThrowMemoryException(e, __FILE__, __LINE__, \
204 | "APR memory allocation failed"); \
205 | goto cleanup; \
206 | } else (void)(0)
207 |
208 | #define TCN_THROW_IF_ERR(x, r) \
209 | TCN_BEGIN_MACRO \
210 | apr_status_t R = (x); \
211 | if (R != APR_SUCCESS) { \
212 | tcn_ThrowAPRException(e, R); \
213 | (r) = 0; \
214 | goto cleanup; \
215 | } \
216 | TCN_END_MACRO
217 |
218 | #define TCN_THROW_OS_ERROR(E) \
219 | tcn_ThrowAPRException((E), apr_get_os_error())
220 |
221 | #define TCN_LOAD_CLASS(E, C, N, R) \
222 | TCN_BEGIN_MACRO \
223 | jclass _##C = (*(E))->FindClass((E), N); \
224 | if (_##C == NULL) { \
225 | (*(E))->ExceptionClear((E)); \
226 | return R; \
227 | } \
228 | C = (*(E))->NewGlobalRef((E), _##C); \
229 | (*(E))->DeleteLocalRef((E), _##C); \
230 | TCN_END_MACRO
231 |
232 | #define TCN_UNLOAD_CLASS(E, C) \
233 | (*(E))->DeleteGlobalRef((E), (C))
234 |
235 | #define TCN_IS_NULL(E, O) \
236 | ((*(E))->IsSameObject((E), (O), NULL) == JNI_TRUE)
237 |
238 | #define TCN_GET_METHOD(E, C, M, N, S, R) \
239 | TCN_BEGIN_MACRO \
240 | M = (*(E))->GetMethodID((E), C, N, S); \
241 | if (M == NULL) { \
242 | return R; \
243 | } \
244 | TCN_END_MACRO
245 |
246 | #define TCN_MAX_METHODS 8
247 |
248 | typedef struct {
249 | jobject obj;
250 | jmethodID mid[TCN_MAX_METHODS];
251 | void *opaque;
252 | } tcn_callback_t;
253 |
254 | #define TCN_MIN(a, b) ((a) < (b) ? (a) : (b))
255 | #define TCN_MAX(a, b) ((a) > (b) ? (a) : (b))
256 |
257 | #ifdef WIN32
258 | #define TCN_ALLOC_WSTRING(V) \
259 | jsize wl##V = (*e)->GetStringLength(e, V); \
260 | const jchar *ws##V = V ? (const jchar *)((*e)->GetStringChars(e, V, 0)) : NULL; \
261 | jchar *w##V = NULL
262 |
263 | #define TCN_INIT_WSTRING(V) \
264 | w##V = (jchar *)malloc((wl##V + 1) * sizeof(jchar)); \
265 | wcsncpy(w##V, ws##V, wl##V); \
266 | w##V[wl##V] = 0
267 |
268 | #define TCN_FREE_WSTRING(V) \
269 | if (ws##V) (*e)->ReleaseStringChars(e, V, ws##V); \
270 | if (ws##V) free (w##V)
271 |
272 | #define J2W(V) w##V
273 |
274 | #endif
275 |
276 | #if !APR_HAVE_IPV6
277 | #define APR_INET6 APR_INET
278 | #endif
279 |
280 | #ifdef APR_UNIX
281 | #define GET_S_FAMILY(T, F) \
282 | if (F == 0) T = APR_UNSPEC; \
283 | else if (F == 1) T = APR_INET; \
284 | else if (F == 2) T = APR_INET6; \
285 | else if (F == 3) T = APR_UNIX; \
286 | else T = F
287 | #else
288 | #define GET_S_FAMILY(T, F) \
289 | if (F == 0) T = APR_UNSPEC; \
290 | else if (F == 1) T = APR_INET; \
291 | else if (F == 2) T = APR_INET6; \
292 | else T = F
293 | #endif
294 |
295 | #define GET_S_TYPE(T, F) \
296 | if (F == 0) T = SOCK_STREAM; \
297 | else if (F == 1) T = SOCK_DGRAM; \
298 | else T = F
299 |
300 | #define TCN_NO_SOCKET_TIMEOUT -2
301 |
302 | #endif /* TCN_H */
303 |
--------------------------------------------------------------------------------
/native/include/tcn_api.h:
--------------------------------------------------------------------------------
1 | /* Licensed to the Apache Software Foundation (ASF) under one or more
2 | * contributor license agreements. See the NOTICE file distributed with
3 | * this work for additional information regarding copyright ownership.
4 | * The ASF licenses this file to You under the Apache License, Version 2.0
5 | * (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef TCN_API_H
18 | #define TCN_API_H
19 |
20 | #include "apr.h"
21 | #include "apr_general.h"
22 | #include "apr_pools.h"
23 | #include "apr_portable.h"
24 | #include "apr_network_io.h"
25 | #include "apr_strings.h"
26 |
27 | #if !APR_HAS_THREADS
28 | #error "Missing threading support from APR."
29 | #endif
30 | #include
31 |
32 | #ifdef __cplusplus
33 | extern "C" {
34 | #endif
35 |
36 | /**
37 | * @file tcn_api.h
38 | * @brief
39 | *
40 | * Tomcat Native Public API
41 | */
42 |
43 | /* Return global apr pool, creating it if necessary
44 | */
45 | apr_pool_t *tcn_get_global_pool(void);
46 |
47 | /* Return global String class
48 | */
49 | jclass tcn_get_string_class(void);
50 |
51 | /* Return global JVM initalized on JNI_OnLoad
52 | */
53 | JavaVM *tcn_get_java_vm(void);
54 |
55 | /* Get current thread JNIEnv
56 | */
57 | jint tcn_get_java_env(JNIEnv **);
58 |
59 | #ifdef __cplusplus
60 | }
61 | #endif
62 |
63 | #endif /* TCN_API_H */
64 |
--------------------------------------------------------------------------------
/native/include/tcn_version.h:
--------------------------------------------------------------------------------
1 | /* Licensed to the Apache Software Foundation (ASF) under one or more
2 | * contributor license agreements. See the NOTICE file distributed with
3 | * this work for additional information regarding copyright ownership.
4 | * The ASF licenses this file to You under the Apache License, Version 2.0
5 | * (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef TCN_VERSION_H
18 | #define TCN_VERSION_H
19 |
20 | #include "apr_version.h"
21 |
22 | #include "tcn.h"
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /**
29 | * @file tcn_version.h
30 | * @brief
31 | *
32 | * Tomcat Native Version
33 | *
34 | * There are several different mechanisms for accessing the version. There
35 | * is a string form, and a set of numbers; in addition, there are constants
36 | * which can be compiled into your application, and you can query the library
37 | * being used for its actual version.
38 | *
39 | * Note that it is possible for an application to detect that it has been
40 | * compiled against a different version of APU by use of the compile-time
41 | * constants and the use of the run-time query function.
42 | *
43 | * TCN version numbering follows the guidelines specified in:
44 | *
45 | * http://apr.apache.org/versioning.html
46 | */
47 |
48 | /* The numeric compile-time version constants. These constants are the
49 | * authoritative version numbers for TCN.
50 | */
51 |
52 | /** major version
53 | * Major API changes that could cause compatibility problems for older
54 | * programs such as structure size changes. No binary compatibility is
55 | * possible across a change in the major version.
56 | */
57 | #define TCN_MAJOR_VERSION 2
58 |
59 | /**
60 | * Minor API changes that do not cause binary compatibility problems.
61 | * Should be reset to 0 when upgrading TCN_MAJOR_VERSION
62 | */
63 | #define TCN_MINOR_VERSION 0
64 |
65 | /** patch level */
66 | #define TCN_PATCH_VERSION 9
67 |
68 | /**
69 | * This symbol is defined for internal, "development" copies of TCN. This
70 | * symbol will be #undef'd for releases.
71 | */
72 | #define TCN_IS_DEV_VERSION 1
73 |
74 |
75 | /** The formatted string of APU's version */
76 | #define TCN_VERSION_STRING \
77 | APR_STRINGIFY(TCN_MAJOR_VERSION) "."\
78 | APR_STRINGIFY(TCN_MINOR_VERSION) "."\
79 | APR_STRINGIFY(TCN_PATCH_VERSION)\
80 | TCN_IS_DEV_STRING
81 |
82 | /** Internal: string form of the "is dev" flag */
83 | #if TCN_IS_DEV_VERSION
84 | #define TCN_IS_DEV_STRING "-dev"
85 | #else
86 | #define TCN_IS_DEV_STRING ""
87 | #endif
88 |
89 | #ifdef __cplusplus
90 | }
91 | #endif
92 |
93 | #endif /* TCN_VERSION_H */
94 |
--------------------------------------------------------------------------------
/native/libtcnative.dsp:
--------------------------------------------------------------------------------
1 | # Microsoft Developer Studio Project File - Name="libtcnative" - Package Owner=<4>
2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00
3 | # ** DO NOT EDIT **
4 |
5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6 |
7 | CFG=libtcnative - Win32 Debug
8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE,
9 | !MESSAGE use the Export Makefile command and run
10 | !MESSAGE
11 | !MESSAGE NMAKE /f "libtcnative.mak".
12 | !MESSAGE
13 | !MESSAGE You can specify a configuration when running NMAKE
14 | !MESSAGE by defining the macro CFG on the command line. For example:
15 | !MESSAGE
16 | !MESSAGE NMAKE /f "libtcnative.mak" CFG="libtcnative - Win32 Debug"
17 | !MESSAGE
18 | !MESSAGE Possible choices for configuration are:
19 | !MESSAGE
20 | !MESSAGE "libtcnative - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21 | !MESSAGE "libtcnative - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22 | !MESSAGE
23 |
24 | # Begin Project
25 | # PROP AllowPerConfigDependencies 0
26 | # PROP Scc_ProjName ""
27 | # PROP Scc_LocalPath ""
28 | CPP=cl.exe
29 | MTL=midl.exe
30 | RSC=rc.exe
31 |
32 | !IF "$(CFG)" == "libtcnative - Win32 Release"
33 |
34 | # PROP BASE Use_MFC 0
35 | # PROP BASE Use_Debug_Libraries 0
36 | # PROP BASE Output_Dir "Release"
37 | # PROP BASE Intermediate_Dir "Release"
38 | # PROP BASE Target_Dir ""
39 | # PROP Use_MFC 0
40 | # PROP Use_Debug_Libraries 0
41 | # PROP Output_Dir "Release"
42 | # PROP Intermediate_Dir "Release"
43 | # PROP Ignore_Export_Lib 0
44 | # PROP Target_Dir ""
45 | # ADD BASE CPP /nologo /MD /W3 /Zi /O2 /Oy- /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
46 | # ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./srclib/apr/include" /I "./srclib/apr/include/arch/win32" /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "./srclib/openssl/inc32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "NO_IDEA" /D "NO_RC5" /D "NO_MDC2" /D "OPENSSL_NO_IDEA" /D "OPENSSL_NO_RC5" /D "OPENSSL_NO_MDC2" /D HAVE_SSL_SET_STATE=1 /Fd"Release\libtcnative_src" /FD /c
47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
49 | # ADD BASE RSC /l 0x409 /d "NDEBUG"
50 | # ADD RSC /l 0x409 /d "NDEBUG"
51 | BSC32=bscmake.exe
52 | # ADD BASE BSC32 /nologo
53 | # ADD BSC32 /nologo
54 | LINK32=link.exe
55 | # ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib psapi.lib ole32.lib shlwapi.lib /nologo /base:"0x6EE00000" /subsystem:windows /dll /debug /machine:I386 /opt:ref
56 | # ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib psapi.lib ole32.lib shlwapi.lib rpcrt4.lib libeay32.lib ssleay32.lib /nologo /base:"0x6EE00000" /subsystem:windows /dll /debug /machine:I386 /out:"Release/libtcnative-2.dll" /libpath:"./srclib/openssl/out32" /libpath:"./srclib/openssl/out32dll" /opt:ref
57 |
58 | !ELSEIF "$(CFG)" == "libtcnative - Win32 Debug"
59 |
60 | # PROP BASE Use_MFC 0
61 | # PROP BASE Use_Debug_Libraries 1
62 | # PROP BASE Output_Dir "Debug"
63 | # PROP BASE Intermediate_Dir "Debug"
64 | # PROP BASE Target_Dir ""
65 | # PROP Use_MFC 0
66 | # PROP Use_Debug_Libraries 1
67 | # PROP Output_Dir "Debug"
68 | # PROP Intermediate_Dir "Debug"
69 | # PROP Ignore_Export_Lib 0
70 | # PROP Target_Dir ""
71 | # ADD BASE CPP /nologo /MDd /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
72 | # ADD CPP /nologo /MDd /W4 /GX /Zi /Od /I "./include" /I "./srclib/apr/include" /I "./srclib/apr/include/arch/win32" /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "./srclib/openssl/inc32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "NO_IDEA" /D "NO_RC5" /D "NO_MDC2" /D "OPENSSL_NO_IDEA" /D "OPENSSL_NO_RC5" /D "OPENSSL_NO_MDC2" /D HAVE_SSL_SET_STATE=1 /Fd"Debug\libtcnative_src" /FD /c
73 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
74 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
75 | # ADD BASE RSC /l 0x409 /d "_DEBUG"
76 | # ADD RSC /l 0x409 /d "_DEBUG"
77 | BSC32=bscmake.exe
78 | # ADD BASE BSC32 /nologo
79 | # ADD BSC32 /nologo
80 | LINK32=link.exe
81 | # ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib psapi.lib ole32.lib shlwapi.lib /nologo /base:"0x6EE00000" /subsystem:windows /dll /incremental:no /debug /machine:I386
82 | # ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib psapi.lib ole32.lib shlwapi.lib rpcrt4.lib libeay32.lib ssleay32.lib /nologo /base:"0x6EE00000" /subsystem:windows /dll /incremental:no /debug /machine:I386 /out:"Debug/libtcnative-2.dll" /libpath:"./srclib/openssl/out32" /libpath:"./srclib/openssl/out32dll"
83 |
84 | !ENDIF
85 |
86 | # Begin Target
87 |
88 | # Name "libtcnative - Win32 Release"
89 | # Name "libtcnative - Win32 Debug"
90 | # Begin Group "Source Files"
91 |
92 | # PROP Default_Filter ""
93 | # Begin Source File
94 |
95 | SOURCE=.\src\bb.c
96 | # End Source File
97 | # Begin Source File
98 |
99 | SOURCE=.\src\error.c
100 | # End Source File
101 | # Begin Source File
102 |
103 | SOURCE=.\src\jnilib.c
104 | # End Source File
105 | # Begin Source File
106 |
107 | SOURCE=.\src\pool.c
108 | # End Source File
109 | # Begin Source File
110 |
111 | SOURCE=.\src\ssl.c
112 | # End Source File
113 | # Begin Source File
114 |
115 | SOURCE=.\src\sslcontext.c
116 | # End Source File
117 | # Begin Source File
118 |
119 | SOURCE=.\src\sslconf.c
120 | # End Source File
121 | # Begin Source File
122 |
123 | SOURCE=.\src\sslutils.c
124 | # End Source File
125 | # End Group
126 | # Begin Group "Generated Files"
127 |
128 | # PROP Default_Filter ""
129 | # End Group
130 | # Begin Group "Header Files"
131 |
132 | # PROP Default_Filter ""
133 | # Begin Source File
134 |
135 | SOURCE=.\include\ssl_private.h
136 | # End Source File
137 | # Begin Source File
138 |
139 | SOURCE=.\include\tcn.h
140 | # End Source File
141 | # Begin Source File
142 |
143 | SOURCE=.\include\tcn_api.h
144 | # End Source File
145 | # Begin Source File
146 |
147 | SOURCE=.\include\tcn_version.h
148 | # End Source File
149 | # End Group
150 | # Begin Group "Platform Files"
151 |
152 | # PROP Default_Filter ""
153 | # Begin Source File
154 |
155 | SOURCE=.\os\win32\system.c
156 | # End Source File
157 | # End Group
158 | # Begin Source File
159 |
160 | SOURCE=.\os\win32\libtcnative.rc
161 | # End Source File
162 | # End Target
163 | # End Project
164 |
--------------------------------------------------------------------------------
/native/libtcnative.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "apr"=..\apr\apr.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | }}}
15 |
16 | ###############################################################################
17 |
18 | Project: "libapr"=..\apr\libapr.dsp - Package Owner=<4>
19 |
20 | Package=<5>
21 | {{{
22 | }}}
23 |
24 | Package=<4>
25 | {{{
26 | }}}
27 |
28 | ###############################################################################
29 |
30 | Project: "libtcnative"=.\libtcnative.dsp - Package Owner=<4>
31 |
32 | Package=<5>
33 | {{{
34 | }}}
35 |
36 | Package=<4>
37 | {{{
38 | Begin Project Dependency
39 | Project_Dep_Name libapr
40 | End Project Dependency
41 | }}}
42 |
43 | ###############################################################################
44 |
45 | Project: "tcnative"=.\tcnative.dsp - Package Owner=<4>
46 |
47 | Package=<5>
48 | {{{
49 | }}}
50 |
51 | Package=<4>
52 | {{{
53 | Begin Project Dependency
54 | Project_Dep_Name apr
55 | End Project Dependency
56 | }}}
57 |
58 | ###############################################################################
59 |
60 | Global:
61 |
62 | Package=<5>
63 | {{{
64 | }}}
65 |
66 | Package=<3>
67 | {{{
68 | }}}
69 |
70 | ###############################################################################
71 |
72 |
--------------------------------------------------------------------------------
/native/os/win32/apache.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/native/os/win32/apache.ico
--------------------------------------------------------------------------------
/native/os/win32/libtcnative.rc:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | LANGUAGE 0x9,0x1
4 |
5 | #define TCN_COPYRIGHT "Licensed to the Apache Software Foundation (ASF) under " \
6 | "one or more contributor license agreements. See the " \
7 | "NOTICE file distributed with this work for additional " \
8 | "information regarding copyright ownership."
9 |
10 | #define TCN_LICENSE "The ASF licenses this file to You under the Apache " \
11 | "License, Version 2.0 (the ""License""); you may not use " \
12 | "this file except in compliance with the License. You " \
13 | "may obtain a copy of the License at\r\n\r\n" \
14 | "http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n" \
15 | "Unless required by applicable law or agreed to in " \
16 | "writing, software distributed under the License is " \
17 | "distributed on an ""AS IS"" BASIS, WITHOUT WARRANTIES " \
18 | "OR CONDITIONS OF ANY KIND, either express or implied. " \
19 | "See the License for the specific language governing " \
20 | "permissions and limitations under the License."
21 |
22 | #define TCN_VERSION "2.0.9"
23 | 1000 ICON "apache.ico"
24 |
25 | 1001 DIALOGEX 0, 0, 252, 51
26 | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_CAPTION
27 | CAPTION "Pass Phrase Prompt"
28 | FONT 8, "MS Shell Dlg", 0, 0, 0x0
29 | BEGIN
30 | ICON 1000,-1,8,6,21,20
31 | LTEXT "Some of your private key files are encrypted for security reasons.\nIn order to read them you have to provide the pass phrases.",
32 | -1,29,5,220,19
33 | LTEXT "Enter pass phrase:",-1,7,28,75,8
34 | EDITTEXT 1002,67,27,174,12,ES_PASSWORD | ES_AUTOHSCROLL
35 | END
36 |
37 | 1 VERSIONINFO
38 | FILEVERSION 2,0,9,0
39 | PRODUCTVERSION 2,0,9,0
40 | FILEFLAGSMASK 0x3fL
41 | #ifdef _DEBUG
42 | FILEFLAGS 0x1L
43 | #else
44 | FILEFLAGS 0x0L
45 | #endif
46 | FILEOS 0x40004L
47 | FILETYPE 0x1L
48 | FILESUBTYPE 0x0L
49 | BEGIN
50 | BLOCK "StringFileInfo"
51 | BEGIN
52 | BLOCK "040904b0"
53 | BEGIN
54 | VALUE "Comments", TCN_LICENSE "\0"
55 | VALUE "CompanyName", "Apache Software Foundation\0"
56 | VALUE "FileDescription", "Tomcat Native Java Library\0"
57 | VALUE "FileVersion", TCN_VERSION "\0"
58 | VALUE "InternalName", "libtcnative-2\0"
59 | VALUE "LegalCopyright", TCN_COPYRIGHT "\0"
60 | VALUE "OriginalFilename", "libtcnative-2.dll\0"
61 | VALUE "ProductName", "Tomcat Native Java Library\0"
62 | VALUE "ProductVersion", TCN_VERSION "\0"
63 | END
64 | END
65 | BLOCK "VarFileInfo"
66 | BEGIN
67 | VALUE "Translation", 0x409, 1200
68 | END
69 | END
70 |
71 |
--------------------------------------------------------------------------------
/native/os/win32/system.c:
--------------------------------------------------------------------------------
1 | /* Licensed to the Apache Software Foundation (ASF) under one or more
2 | * contributor license agreements. See the NOTICE file distributed with
3 | * this work for additional information regarding copyright ownership.
4 | * The ASF licenses this file to You under the Apache License, Version 2.0
5 | * (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | #include "apr.h"
23 | #include "apr_pools.h"
24 | #include "apr_poll.h"
25 | #include "apr_network_io.h"
26 | #include "apr_arch_misc.h" /* for apr_os_level */
27 |
28 | #include "tcn.h"
29 | #include "ssl_private.h"
30 |
31 | #pragma warning(push)
32 | #pragma warning(disable : 4201)
33 | #include
34 | #pragma warning(pop)
35 |
36 |
37 | static CRITICAL_SECTION dll_critical_section; /* dll's critical section */
38 | static HINSTANCE dll_instance = NULL;
39 |
40 | BOOL
41 | WINAPI
42 | DllMain(
43 | HINSTANCE instance,
44 | DWORD reason,
45 | LPVOID reserved)
46 | {
47 |
48 | switch (reason) {
49 | /** The DLL is loading due to process
50 | * initialization or a call to LoadLibrary.
51 | */
52 | case DLL_PROCESS_ATTACH:
53 | InitializeCriticalSection(&dll_critical_section);
54 | dll_instance = instance;
55 | break;
56 | /** The attached process creates a new thread.
57 | */
58 | case DLL_THREAD_ATTACH:
59 | break;
60 |
61 | /** The thread of the attached process terminates.
62 | */
63 | case DLL_THREAD_DETACH:
64 | ERR_remove_thread_state(NULL);
65 | break;
66 |
67 | /** DLL unload due to process termination
68 | * or FreeLibrary.
69 | */
70 | case DLL_PROCESS_DETACH:
71 | DeleteCriticalSection(&dll_critical_section);
72 | break;
73 |
74 | default:
75 | break;
76 | }
77 |
78 | return TRUE;
79 | UNREFERENCED_PARAMETER(reserved);
80 | }
81 |
82 |
83 | static DWORD WINAPI password_thread(void *data)
84 | {
85 | tcn_pass_cb_t *cb = (tcn_pass_cb_t *)data;
86 | MSG msg;
87 | HWINSTA hwss;
88 | HWINSTA hwsu;
89 | HDESK hwds;
90 | HDESK hwdu;
91 | HWND hwnd;
92 |
93 | /* Ensure connection to service window station and desktop, and
94 | * save their handles.
95 | */
96 | GetDesktopWindow();
97 | hwss = GetProcessWindowStation();
98 | hwds = GetThreadDesktop(GetCurrentThreadId());
99 |
100 | /* Impersonate the client and connect to the User's
101 | * window station and desktop.
102 | */
103 | hwsu = OpenWindowStation("WinSta0", FALSE, MAXIMUM_ALLOWED);
104 | if (hwsu == NULL) {
105 | ExitThread(1);
106 | return 1;
107 | }
108 | SetProcessWindowStation(hwsu);
109 | hwdu = OpenDesktop("Default", 0, FALSE, MAXIMUM_ALLOWED);
110 | if (hwdu == NULL) {
111 | SetProcessWindowStation(hwss);
112 | CloseWindowStation(hwsu);
113 | ExitThread(1);
114 | return 1;
115 | }
116 | SetThreadDesktop(hwdu);
117 |
118 | hwnd = CreateDialog(dll_instance, MAKEINTRESOURCE(1001), NULL, NULL);
119 | if (hwnd != NULL)
120 | ShowWindow(hwnd, SW_SHOW);
121 | else {
122 | ExitThread(1);
123 | return 1;
124 | }
125 | while (1) {
126 | if (PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE)) {
127 | if (msg.message == WM_KEYUP) {
128 | int nVirtKey = (int)msg.wParam;
129 | if (nVirtKey == VK_ESCAPE) {
130 | DestroyWindow(hwnd);
131 | break;
132 | }
133 | else if (nVirtKey == VK_RETURN) {
134 | HWND he = GetDlgItem(hwnd, 1002);
135 | if (he) {
136 | int n = GetWindowText(he, cb->password, SSL_MAX_PASSWORD_LEN - 1);
137 | cb->password[n] = '\0';
138 | }
139 | DestroyWindow(hwnd);
140 | break;
141 | }
142 | }
143 | TranslateMessage(&msg);
144 | DispatchMessage(&msg);
145 | }
146 | else
147 | Sleep(100);
148 | }
149 | /* Restore window station and desktop.
150 | */
151 | SetThreadDesktop(hwds);
152 | SetProcessWindowStation(hwss);
153 | CloseDesktop(hwdu);
154 | CloseWindowStation(hwsu);
155 |
156 | ExitThread(0);
157 | return 0;
158 | }
159 |
160 | int WIN32_SSL_password_prompt(tcn_pass_cb_t *data)
161 | {
162 | DWORD id;
163 | HANDLE thread;
164 | /* TODO: See how to display this from service mode */
165 | thread = CreateThread(NULL, 0,
166 | password_thread, data,
167 | 0, &id);
168 | WaitForSingleObject(thread, INFINITE);
169 | CloseHandle(thread);
170 | return (int)strlen(data->password);
171 | }
172 |
--------------------------------------------------------------------------------
/native/src/bb.c:
--------------------------------------------------------------------------------
1 | /* Licensed to the Apache Software Foundation (ASF) under one or more
2 | * contributor license agreements. See the NOTICE file distributed with
3 | * this work for additional information regarding copyright ownership.
4 | * The ASF licenses this file to You under the Apache License, Version 2.0
5 | * (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #include "tcn.h"
18 |
19 | /**
20 | * DirectByteBuffer utilities
21 | */
22 |
23 | TCN_IMPLEMENT_CALL(jlong, Buffer, address)(TCN_STDARGS, jobject bb)
24 | {
25 | UNREFERENCED(o);
26 | return P2J((*e)->GetDirectBufferAddress(e, bb));
27 | }
28 |
--------------------------------------------------------------------------------
/native/src/error.c:
--------------------------------------------------------------------------------
1 | /* Licensed to the Apache Software Foundation (ASF) under one or more
2 | * contributor license agreements. See the NOTICE file distributed with
3 | * this work for additional information regarding copyright ownership.
4 | * The ASF licenses this file to You under the Apache License, Version 2.0
5 | * (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #include "tcn.h"
18 |
19 | /* Merge IS_ETIMEDOUT with APR_TIMEUP
20 | */
21 | #define TCN_STATUS_IS_ETIMEDOUT(x) (APR_STATUS_IS_ETIMEDOUT((x)) || ((x) == APR_TIMEUP))
22 | /*
23 | * Convenience function to help throw an java.lang.Exception.
24 | */
25 | void tcn_ThrowException(JNIEnv *env, const char *msg)
26 | {
27 | jclass javaExceptionClass;
28 |
29 | javaExceptionClass = (*env)->FindClass(env, "java/lang/Exception");
30 | if (javaExceptionClass == NULL) {
31 | fprintf(stderr, "Cannot find java/lang/Exception class\n");
32 | return;
33 | }
34 | (*env)->ThrowNew(env, javaExceptionClass, msg);
35 | (*env)->DeleteLocalRef(env, javaExceptionClass);
36 |
37 | }
38 |
39 | void tcn_ThrowMemoryException(JNIEnv *env, const char *file, int line, const char *msg)
40 | {
41 | jclass javaExceptionClass;
42 | javaExceptionClass = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
43 | if (javaExceptionClass == NULL) {
44 | fprintf(stderr, "Cannot find java/lang/OutOfMemoryError\n");
45 | return;
46 | }
47 |
48 | if (file) {
49 | char fmt[TCN_BUFFER_SZ];
50 | char *f = (char *)(file + strlen(file) - 1);
51 | while (f != file && '\\' != *f && '/' != *f) {
52 | f--;
53 | }
54 | if (f != file) {
55 | f++;
56 | }
57 | sprintf(fmt, "%s for [%04d@%s]", msg, line, f);
58 | (*env)->ThrowNew(env, javaExceptionClass, &fmt[0]);
59 | }
60 | else
61 | (*env)->ThrowNew(env, javaExceptionClass, msg);
62 | (*env)->DeleteLocalRef(env, javaExceptionClass);
63 |
64 | }
65 |
66 |
67 | void tcn_Throw(JNIEnv *env, const char *fmt, ...)
68 | {
69 | char msg[TCN_BUFFER_SZ] = {'\0'};
70 | va_list ap;
71 |
72 | va_start(ap, fmt);
73 | apr_vsnprintf(msg, TCN_BUFFER_SZ, fmt, ap);
74 | tcn_ThrowException(env, msg);
75 | va_end(ap);
76 | }
77 |
78 | /*
79 | * Convenience function to help throw an APR Exception
80 | * from native error code.
81 | */
82 | void tcn_ThrowAPRException(JNIEnv *e, apr_status_t err)
83 | {
84 | jclass aprErrorClass;
85 | jmethodID constructorID = 0;
86 | jobject throwObj;
87 | jstring jdescription;
88 | char serr[512] = {0};
89 |
90 | aprErrorClass = (*e)->FindClass(e, TCN_ERROR_CLASS);
91 | if (aprErrorClass == NULL) {
92 | fprintf(stderr, "Cannot find " TCN_ERROR_CLASS " class\n");
93 | return;
94 | }
95 |
96 | /* Find the constructor ID */
97 | constructorID = (*e)->GetMethodID(e, aprErrorClass,
98 | "",
99 | "(ILjava/lang/String;)V");
100 | if (constructorID == NULL) {
101 | fprintf(stderr,
102 | "Cannot find constructor for " TCN_ERROR_CLASS " class\n");
103 | goto cleanup;
104 | }
105 |
106 | apr_strerror(err, serr, 512);
107 | /* Obtain the string objects */
108 | jdescription = AJP_TO_JSTRING(serr);
109 | if (jdescription == NULL) {
110 | fprintf(stderr,
111 | "Cannot allocate description for " TCN_ERROR_CLASS " class\n");
112 | goto cleanup;
113 | }
114 | /* Create the APR Error object */
115 | throwObj = (*e)->NewObject(e, aprErrorClass, constructorID,
116 | (jint)err, jdescription);
117 | if (throwObj == NULL) {
118 | fprintf(stderr,
119 | "Cannot allocate new " TCN_ERROR_CLASS " object\n");
120 | goto cleanup;
121 | }
122 |
123 | (*e)->Throw(e, throwObj);
124 | cleanup:
125 | (*e)->DeleteLocalRef(e, aprErrorClass);
126 | }
127 |
--------------------------------------------------------------------------------
/native/src/pool.c:
--------------------------------------------------------------------------------
1 | /* Licensed to the Apache Software Foundation (ASF) under one or more
2 | * contributor license agreements. See the NOTICE file distributed with
3 | * this work for additional information regarding copyright ownership.
4 | * The ASF licenses this file to You under the Apache License, Version 2.0
5 | * (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #include "tcn.h"
18 |
19 | extern apr_pool_t *tcn_global_pool;
20 |
21 | TCN_IMPLEMENT_CALL(jlong, Pool, create)(TCN_STDARGS, jlong parent)
22 | {
23 | apr_pool_t *p = J2P(parent, apr_pool_t *);
24 | apr_pool_t *n;
25 |
26 | UNREFERENCED(o);
27 | /* Make sure our global pool is ancestor for all pools */
28 | if (p == NULL)
29 | p = tcn_global_pool;
30 | TCN_THROW_IF_ERR(apr_pool_create(&n, p), n);
31 | cleanup:
32 | return P2J(n);
33 | }
34 |
35 | TCN_IMPLEMENT_CALL(void, Pool, destroy)(TCN_STDARGS, jlong pool)
36 | {
37 | apr_pool_t *p = J2P(pool, apr_pool_t *);
38 | UNREFERENCED_STDARGS;
39 | TCN_ASSERT(pool != 0);
40 | if (tcn_global_pool)
41 | apr_pool_destroy(p);
42 | }
43 |
--------------------------------------------------------------------------------
/native/srclib/BUILDING:
--------------------------------------------------------------------------------
1 | Building apr on windows
2 | -----------------------
3 |
4 | For 32-bit windows use
5 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
6 | > nmake -f NMAKEmakefile CPU=X86 APR_DECLARE_STATIC=1
7 |
8 | For 64-bit windows use
9 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
10 | > nmake -f NMAKEmakefile CPU=X64 APR_DECLARE_STATIC=1
11 |
12 |
13 | Building OpenSSL 3.0.0 and later
14 | ----------------------------------
15 |
16 | For 32-bit Windows use
17 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
18 | > perl Configure no-shared VC-WIN32
19 | > nmake
20 |
21 | For 64-bit Windows use
22 | > "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
23 | > perl Configure no-shared VC-WIN64A
24 | > nmake
25 |
26 |
27 | For a step-by-step guide to building OpenSSL on Windows see:
28 | https://cwiki.apache.org/confluence/display/TOMCAT/Building+the+Tomcat+Native+Connector+binaries+for+Windows
29 |
--------------------------------------------------------------------------------
/native/srclib/VERSIONS:
--------------------------------------------------------------------------------
1 | The current minimum versions are:
2 | - OpenSSL 3.0.0
3 | - APR 1.7.0
4 |
5 | The following version of the libraries are recommended:
6 |
7 | - APR 1.7.6 or later, http://apr.apache.org
8 | - OpenSSL 3.5.0 or later, http://www.openssl.org
9 |
10 | Older versions should also work but are not as thoroughly tested by the Tomcat
11 | Native team
12 |
--------------------------------------------------------------------------------
/native/srclib/apr/NMAKEmakefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 | # ====================================================================
17 | #
18 | # NMAKEmakefile APR makefile.
19 | # Usage:
20 | # DLL=1 Build DLL version
21 | # DEBUG=1 Build DEBUG version of APR
22 | #
23 | # Originally contributed by Mladen Turk
24 | #
25 | # ====================================================================
26 | #
27 |
28 | !IF !DEFINED(APR_DECLARE_STATIC) || "$(APR_DECLARE_STATIC)" == ""
29 | TARGET=DLL
30 | EXTRA_CFLAGS = -DAPR_DECLARE_EXPORT
31 | PROJECT = libapr-1
32 | !ELSE
33 | TARGET=LIB
34 | EXTRA_CFLAGS = -DAPR_DECLARE_STATIC
35 | PROJECT = apr-1
36 | !ENDIF
37 |
38 | !IF !DEFINED(SRCDIR) || "$(SRCDIR)" == ""
39 | SRCDIR = .
40 | !ENDIF
41 |
42 | !include <..\..\NMAKEMakefile.inc>
43 |
44 |
45 | !IF "$(TARGET)" != "LIB"
46 | LFLAGS = $(LFLAGS) /version:1.4
47 | !ENDIF
48 | INCLUDES = -I$(SRCDIR)\include -I$(SRCDIR)\include\arch -I$(SRCDIR)\include\private -I$(SRCDIR)\include\arch\win32 -I$(SRCDIR)\include\arch\unix
49 | PDBFLAGS = -Fo$(WORKDIR)\ -Fd$(WORKDIR)\$(PROJECT)
50 |
51 | OBJECTS = \
52 | $(WORKDIR)\apr_atomic.obj \
53 | $(WORKDIR)\apr_atomic64.obj \
54 | $(WORKDIR)\apr_cpystrn.obj \
55 | $(WORKDIR)\apr_cstr.obj \
56 | $(WORKDIR)\apr_encode.obj \
57 | $(WORKDIR)\apr_escape.obj \
58 | $(WORKDIR)\apr_fnmatch.obj \
59 | $(WORKDIR)\apr_getpass.obj \
60 | $(WORKDIR)\apr_hash.obj \
61 | $(WORKDIR)\apr_pools.obj \
62 | $(WORKDIR)\apr_random.obj \
63 | $(WORKDIR)\apr_skiplist.obj \
64 | $(WORKDIR)\apr_snprintf.obj \
65 | $(WORKDIR)\apr_strings.obj \
66 | $(WORKDIR)\apr_strnatcmp.obj \
67 | $(WORKDIR)\apr_strtok.obj \
68 | $(WORKDIR)\apr_tables.obj \
69 | $(WORKDIR)\buffer.obj \
70 | $(WORKDIR)\charset.obj \
71 | $(WORKDIR)\common.obj \
72 | $(WORKDIR)\copy.obj \
73 | $(WORKDIR)\dir.obj \
74 | $(WORKDIR)\dso.obj \
75 | $(WORKDIR)\env.obj \
76 | $(WORKDIR)\errorcodes.obj \
77 | $(WORKDIR)\fileacc.obj \
78 | $(WORKDIR)\filedup.obj \
79 | $(WORKDIR)\filepath.obj \
80 | $(WORKDIR)\filepath_util.obj \
81 | $(WORKDIR)\filestat.obj \
82 | $(WORKDIR)\filesys.obj \
83 | $(WORKDIR)\flock.obj \
84 | $(WORKDIR)\fullrw.obj \
85 | $(WORKDIR)\getopt.obj \
86 | $(WORKDIR)\groupinfo.obj \
87 | $(WORKDIR)\inet_ntop.obj \
88 | $(WORKDIR)\inet_pton.obj \
89 | $(WORKDIR)\internal.obj \
90 | $(WORKDIR)\misc.obj \
91 | $(WORKDIR)\mktemp.obj \
92 | $(WORKDIR)\mmap.obj \
93 | $(WORKDIR)\multicast.obj \
94 | $(WORKDIR)\open.obj \
95 | $(WORKDIR)\otherchild.obj \
96 | $(WORKDIR)\pipe.obj \
97 | $(WORKDIR)\poll.obj \
98 | $(WORKDIR)\pollcb.obj \
99 | $(WORKDIR)\pollset.obj \
100 | $(WORKDIR)\proc.obj \
101 | $(WORKDIR)\proc_mutex.obj \
102 | $(WORKDIR)\rand.obj \
103 | $(WORKDIR)\readwrite.obj \
104 | $(WORKDIR)\seek.obj \
105 | $(WORKDIR)\select.obj \
106 | $(WORKDIR)\sendrecv.obj \
107 | $(WORKDIR)\sha2.obj \
108 | $(WORKDIR)\sha2_glue.obj \
109 | $(WORKDIR)\shm.obj \
110 | $(WORKDIR)\signals.obj \
111 | $(WORKDIR)\sockaddr.obj \
112 | $(WORKDIR)\socket_util.obj \
113 | $(WORKDIR)\sockets.obj \
114 | $(WORKDIR)\sockopt.obj \
115 | $(WORKDIR)\start.obj \
116 | $(WORKDIR)\tempdir.obj \
117 | $(WORKDIR)\thread.obj \
118 | $(WORKDIR)\thread_cond.obj \
119 | $(WORKDIR)\thread_mutex.obj \
120 | $(WORKDIR)\thread_rwlock.obj \
121 | $(WORKDIR)\threadpriv.obj \
122 | $(WORKDIR)\time.obj \
123 | $(WORKDIR)\timestr.obj \
124 | $(WORKDIR)\userinfo.obj \
125 | $(WORKDIR)\utf8.obj \
126 | $(WORKDIR)\version.obj \
127 | $(WORKDIR)\wakeup.obj
128 |
129 | HEADERS = \
130 | $(SRCDIR)\include\apr.h \
131 | $(SRCDIR)\include\private\apr_escape_test_char.h
132 |
133 |
134 | BUILDINC = $(PREFIX)\include\apr-1
135 | BUILDLIB = $(PREFIX)\lib
136 | !IF "$(TARGET)" == "DLL"
137 | BUILDBIN = $(WORKDIR)\$(PROJECT).dll
138 | BUILDPDB = $(WORKDIR)\$(PROJECT).pdb
139 | BUILDRES = $(WORKDIR)\$(PROJECT).res
140 | BUILDIMP = $(WORKDIR)\$(PROJECT).lib
141 | !ELSE
142 | BUILDBIN = $(WORKDIR)\$(PROJECT).lib
143 | !ENDIF
144 |
145 | all : $(WORKDIR) $(HEADERS) $(BUILDBIN)
146 |
147 | $(WORKDIR):
148 | @$(MAKEWORKDIR)
149 |
150 | $(SRCDIR)\include\apr.h: $(SRCDIR)\include\apr.hw
151 | @type $** > $@
152 |
153 | $(SRCDIR)\include\private\apr_escape_test_char.h: $(SRCDIR)\tools\gen_test_char.c
154 | $(CC) /nologo -MT -W3 -O2 -Ob2 -DWIN32 -D_WIN32 -D_CONSOLE -D_MBCS /Fo$(WORKDIR)\ /Fe$(WORKDIR)\gen_test_char.exe $**
155 | $(WORKDIR)\gen_test_char.exe > $@
156 |
157 | {$(SRCDIR)\atomic\win32}.c{$(WORKDIR)}.obj:
158 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
159 |
160 | {$(SRCDIR)\dso\win32}.c{$(WORKDIR)}.obj:
161 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
162 |
163 | {$(SRCDIR)\encoding}.c{$(WORKDIR)}.obj:
164 | $(CC) $(CFLAGS) $(INCLUDES) -I$(WORKDIR) $(PDBFLAGS) $<
165 |
166 | {$(SRCDIR)\file_io\unix}.c{$(WORKDIR)}.obj:
167 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
168 |
169 | {$(SRCDIR)\file_io\win32}.c{$(WORKDIR)}.obj:
170 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
171 |
172 | {$(SRCDIR)\locks\win32}.c{$(WORKDIR)}.obj:
173 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
174 |
175 | {$(SRCDIR)\memory\unix}.c{$(WORKDIR)}.obj:
176 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
177 |
178 | {$(SRCDIR)\misc\unix}.c{$(WORKDIR)}.obj:
179 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
180 |
181 | {$(SRCDIR)\misc\win32}.c{$(WORKDIR)}.obj:
182 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
183 |
184 | {$(SRCDIR)\mmap\unix}.c{$(WORKDIR)}.obj:
185 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
186 |
187 | {$(SRCDIR)\mmap\win32}.c{$(WORKDIR)}.obj:
188 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
189 |
190 | {$(SRCDIR)\network_io\unix}.c{$(WORKDIR)}.obj:
191 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
192 |
193 | {$(SRCDIR)\network_io\win32}.c{$(WORKDIR)}.obj:
194 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
195 |
196 | {$(SRCDIR)\passwd}.c{$(WORKDIR)}.obj:
197 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
198 |
199 | {$(SRCDIR)\poll\unix}.c{$(WORKDIR)}.obj:
200 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
201 |
202 | {$(SRCDIR)\random\unix}.c{$(WORKDIR)}.obj:
203 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
204 |
205 | {$(SRCDIR)\shmem\win32}.c{$(WORKDIR)}.obj:
206 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
207 |
208 | {$(SRCDIR)\strings}.c{$(WORKDIR)}.obj:
209 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
210 |
211 | {$(SRCDIR)\tables}.c{$(WORKDIR)}.obj:
212 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
213 |
214 | {$(SRCDIR)\threadproc\win32}.c{$(WORKDIR)}.obj:
215 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
216 |
217 | {$(SRCDIR)\time\win32}.c{$(WORKDIR)}.obj:
218 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
219 |
220 | {$(SRCDIR)\user\win32}.c{$(WORKDIR)}.obj:
221 | $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
222 |
223 | !IF "$(TARGET)" == "DLL"
224 | $(BUILDRES): $(SRCDIR)\libapr.rc
225 | $(RC) $(RCFLAGS) /i "$(SRCDIR)\include" /d "APR_VERSION_ONLY" /fo $(BUILDRES) $**
226 | $(BUILDBIN): $(OBJECTS) $(BUILDRES)
227 | $(LINK) $(LFLAGS) $** $(LIBS) /pdb:$(BUILDPDB) /out:$(BUILDBIN) /implib:$(BUILDIMP)
228 | !ELSE
229 | $(BUILDBIN): $(OBJECTS)
230 | $(LINK) $(LFLAGS) $** /out:$(BUILDBIN)
231 | !ENDIF
232 |
233 | clean:
234 | @$(CLEANTARGET)
235 |
236 | install: all
237 | @xcopy /I /Y /Q "$(SRCDIR)\include\*.h" "$(BUILDINC)"
238 | @xcopy /I /Y /Q "$(SRCDIR)\include\arch\*.h" "$(BUILDINC)\arch"
239 | @xcopy /I /Y /Q "$(SRCDIR)\include\arch\win32\*.h" "$(BUILDINC)\arch\win32"
240 | @xcopy /I /Y /Q "$(WORKDIR)\*.lib" "$(BUILDLIB)"
241 | @xcopy /I /Y /Q "$(WORKDIR)\*.dll" "$(BUILDLIB)" 2>NUL
242 |
243 |
--------------------------------------------------------------------------------
/native/srclib/openssl/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/native/srclib/openssl/.gitkeep
--------------------------------------------------------------------------------
/native/tcnative.dsp:
--------------------------------------------------------------------------------
1 | # Microsoft Developer Studio Project File - Name="tcnative" - Package Owner=<4>
2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00
3 | # ** DO NOT EDIT **
4 |
5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6 |
7 | CFG=tcnative - Win32 Debug
8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE,
9 | !MESSAGE use the Export Makefile command and run
10 | !MESSAGE
11 | !MESSAGE NMAKE /f "tcnative.mak".
12 | !MESSAGE
13 | !MESSAGE You can specify a configuration when running NMAKE
14 | !MESSAGE by defining the macro CFG on the command line. For example:
15 | !MESSAGE
16 | !MESSAGE NMAKE /f "tcnative.mak" CFG="tcnative - Win32 Debug"
17 | !MESSAGE
18 | !MESSAGE Possible choices for configuration are:
19 | !MESSAGE
20 | !MESSAGE "tcnative - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21 | !MESSAGE "tcnative - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22 | !MESSAGE
23 |
24 | # Begin Project
25 | # PROP AllowPerConfigDependencies 0
26 | # PROP Scc_ProjName ""
27 | # PROP Scc_LocalPath ""
28 | CPP=cl.exe
29 | MTL=midl.exe
30 | RSC=rc.exe
31 |
32 | !IF "$(CFG)" == "tcnative - Win32 Release"
33 |
34 | # PROP BASE Use_MFC 0
35 | # PROP BASE Use_Debug_Libraries 0
36 | # PROP BASE Output_Dir "Release"
37 | # PROP BASE Intermediate_Dir "Release"
38 | # PROP BASE Target_Dir ""
39 | # PROP Use_MFC 0
40 | # PROP Use_Debug_Libraries 0
41 | # PROP Output_Dir "LibR"
42 | # PROP Intermediate_Dir "LibR"
43 | # PROP Ignore_Export_Lib 0
44 | # PROP Target_Dir ""
45 | # ADD BASE CPP /nologo /MD /W3 /Zi /O2 /Oy- /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
46 | # ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./srclib/apr/include" /I "./srclib/apr/include/arch/win32" /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "./srclib/openssl/inc32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "APR_DECLARE_STATIC" /D "NO_IDEA" /D "NO_RC5" /D "NO_MDC2" /D "OPENSSL_NO_IDEA" /D "OPENSSL_NO_RC5" /D "OPENSSL_NO_MDC2" /D HAVE_SSL_SET_STATE=1 /Fd"LibR\tcnative_src" /FD /c
47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
49 | # ADD BASE RSC /l 0x409 /d "NDEBUG"
50 | # ADD RSC /l 0x409 /d "NDEBUG"
51 | BSC32=bscmake.exe
52 | # ADD BASE BSC32 /nologo
53 | # ADD BSC32 /nologo
54 | LINK32=link.exe
55 | # ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib psapi.lib ole32.lib shlwapi.lib /nologo /base:"0x6EE00000" /subsystem:windows /dll /debug /machine:I386 /opt:ref
56 | # ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib psapi.lib ole32.lib shlwapi.lib rpcrt4.lib libeay32.lib ssleay32.lib /nologo /base:"0x6EE00000" /subsystem:windows /dll /debug /machine:I386 /out:"LibR/tcnative-2.dll" /libpath:"./srclib/openssl/out32" /libpath:"./srclib/openssl/out32dll" /opt:ref
57 |
58 | !ELSEIF "$(CFG)" == "tcnative - Win32 Debug"
59 |
60 | # PROP BASE Use_MFC 0
61 | # PROP BASE Use_Debug_Libraries 1
62 | # PROP BASE Output_Dir "Debug"
63 | # PROP BASE Intermediate_Dir "Debug"
64 | # PROP BASE Target_Dir ""
65 | # PROP Use_MFC 0
66 | # PROP Use_Debug_Libraries 1
67 | # PROP Output_Dir "LibD"
68 | # PROP Intermediate_Dir "LibD"
69 | # PROP Ignore_Export_Lib 0
70 | # PROP Target_Dir ""
71 | # ADD BASE CPP /nologo /MDd /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
72 | # ADD CPP /nologo /MDd /W4 /GX /Zi /Od /I "./include" /I "./srclib/apr/include" /I "./srclib/apr/include/arch/win32" /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "./srclib/openssl/inc32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "APR_DECLARE_STATIC" /D "NO_IDEA" /D "NO_RC5" /D "NO_MDC2" /D "OPENSSL_NO_IDEA" /D "OPENSSL_NO_RC5" /D "OPENSSL_NO_MDC2" /D HAVE_SSL_SET_STATE=1 /Fd"LibD\tcnative_src" /FD /c
73 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
74 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
75 | # ADD BASE RSC /l 0x409 /d "_DEBUG"
76 | # ADD RSC /l 0x409 /d "_DEBUG"
77 | BSC32=bscmake.exe
78 | # ADD BASE BSC32 /nologo
79 | # ADD BSC32 /nologo
80 | LINK32=link.exe
81 | # ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib psapi.lib ole32.lib shlwapi.lib /nologo /base:"0x6EE00000" /subsystem:windows /dll /incremental:no /debug /machine:I386
82 | # ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib psapi.lib ole32.lib shlwapi.lib rpcrt4.lib libeay32.lib ssleay32.lib /nologo /base:"0x6EE00000" /subsystem:windows /dll /incremental:no /debug /machine:I386 /out:"LibD/tcnative-2.dll" /libpath:"./srclib/openssl/out32" /libpath:"./srclib/openssl/out32dll"
83 |
84 | !ENDIF
85 |
86 | # Begin Target
87 |
88 | # Name "tcnative - Win32 Release"
89 | # Name "tcnative - Win32 Debug"
90 | # Begin Group "Source Files"
91 |
92 | # PROP Default_Filter ""
93 | # Begin Source File
94 |
95 | SOURCE=.\src\bb.c
96 | # End Source File
97 | # Begin Source File
98 |
99 | SOURCE=.\src\error.c
100 | # End Source File
101 | # Begin Source File
102 |
103 | SOURCE=.\src\jnilib.c
104 | # End Source File
105 | # Begin Source File
106 |
107 | SOURCE=.\src\pool.c
108 | # End Source File
109 | # Begin Source File
110 |
111 | SOURCE=.\src\ssl.c
112 | # End Source File
113 | # Begin Source File
114 |
115 | SOURCE=.\src\sslcontext.c
116 | # End Source File
117 | # Begin Source File
118 |
119 | SOURCE=.\src\sslconf.c
120 | # End Source File
121 | # Begin Source File
122 |
123 | SOURCE=.\src\sslutils.c
124 | # End Source File
125 | # End Group
126 | # Begin Group "Generated Files"
127 |
128 | # PROP Default_Filter ""
129 | # End Group
130 | # Begin Group "Header Files"
131 |
132 | # PROP Default_Filter ""
133 | # Begin Source File
134 |
135 | SOURCE=.\include\ssl_private.h
136 | # End Source File
137 | # Begin Source File
138 |
139 | SOURCE=.\include\tcn.h
140 | # End Source File
141 | # Begin Source File
142 |
143 | SOURCE=.\include\tcn_api.h
144 | # End Source File
145 | # Begin Source File
146 |
147 | SOURCE=.\include\tcn_version.h
148 | # End Source File
149 | # End Group
150 | # Begin Group "Platform Files"
151 |
152 | # PROP Default_Filter ""
153 | # Begin Source File
154 |
155 | SOURCE=.\os\win32\system.c
156 | # End Source File
157 | # End Group
158 | # Begin Source File
159 |
160 | SOURCE=.\os\win32\libtcnative.rc
161 | # End Source File
162 | # End Target
163 | # End Project
164 |
--------------------------------------------------------------------------------
/test/org/apache/tomcat/jni/TesterSSL.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.apache.tomcat.jni;
18 |
19 | import org.junit.Test;
20 |
21 | /*
22 | * Helper class to investigate native memory leaks. Needs to be used with tools
23 | * to monitor native memory usage.
24 | *
25 | * Note: Moving the Pool, SSLContext, SSL and BIO creation in/out of the loop
26 | * can help identify where the memory is leaking.
27 | */
28 | public class TesterSSL {
29 |
30 | @Test
31 | public void testCreateDestroy() throws Exception {
32 | Library.initialize(null);
33 | SSL.initialize(null);
34 |
35 | long memoryPool = Pool.create(0);
36 | long sslCtx = SSLContext.make(memoryPool, SSL.SSL_PROTOCOL_ALL, SSL.SSL_MODE_SERVER);
37 |
38 | for (int i = 0; i < 10000000; i++) {
39 | doNative(sslCtx);
40 | if (i % 1000 == 0) {
41 | System.gc();
42 | }
43 | }
44 |
45 | SSLContext.free(sslCtx);
46 | Pool.destroy(memoryPool);
47 |
48 | System.gc();
49 | }
50 |
51 |
52 | private void doNative(long sslCtx) throws Exception {
53 | long ssl = SSL.newSSL(sslCtx, true);
54 | long bio = SSL.makeNetworkBIO(ssl);
55 | SSL.freeBIO(bio);
56 | SSL.freeSSL(ssl);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/xdocs/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
121 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
135 |
136 |
137 |
138 |
--------------------------------------------------------------------------------
/xdocs/images/add.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/add.gif
--------------------------------------------------------------------------------
/xdocs/images/code.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/code.gif
--------------------------------------------------------------------------------
/xdocs/images/design.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/design.gif
--------------------------------------------------------------------------------
/xdocs/images/docs-stylesheet.css:
--------------------------------------------------------------------------------
1 | @charset "utf-8";
2 | /*
3 | Licensed to the Apache Software Foundation (ASF) under one or more
4 | contributor license agreements. See the NOTICE file distributed with
5 | this work for additional information regarding copyright ownership.
6 | The ASF licenses this file to You under the Apache License, Version 2.0
7 | (the "License"); you may not use this file except in compliance with
8 | the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 | */
18 |
19 |
20 | /* General style */
21 |
22 | body {
23 | margin: 0;
24 | }
25 |
26 | body, input {
27 | font-family: 'Lucida Sans Unicode', Arial, Helvetica, sans-serif;
28 | font-size: 10.5pt;
29 | }
30 |
31 | code, pre {
32 | font-family: Consolas, monospace;
33 | }
34 |
35 | img {
36 | border: 0;
37 | }
38 |
39 | table {
40 | border-collapse: collapse;
41 | text-align: left;
42 | }
43 | table *:not(table) {
44 | /* Prevent border-collapsing for table child elements like
s from taking the complete available width. */
225 | /*
226 | When it is officially supported, use the following CSS instead of display: table
227 | to prevent big
*/
294 | #comments_thread h1, #comments_thread h2, #comments_thread h3, #comments_thread h4, #comments_thread h5, #comments_thread h6 {
295 | border: none;
296 | background-color: transparent;
297 | }
--------------------------------------------------------------------------------
/xdocs/images/docs.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/docs.gif
--------------------------------------------------------------------------------
/xdocs/images/fix.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/fix.gif
--------------------------------------------------------------------------------
/xdocs/images/printer.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/printer.gif
--------------------------------------------------------------------------------
/xdocs/images/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | p.todo {
19 | margin-left: 20px;
20 | margin-right: 10px;
21 | text-align: justify;
22 | font-size: smaller;
23 | }
24 |
--------------------------------------------------------------------------------
/xdocs/images/tomcat.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/tomcat.gif
--------------------------------------------------------------------------------
/xdocs/images/tomcat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/tomcat.png
--------------------------------------------------------------------------------
/xdocs/images/update.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/update.gif
--------------------------------------------------------------------------------
/xdocs/images/void.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/tomcat-native/82c308fd433e367f1300c687d6b409d32304ba9a/xdocs/images/void.gif
--------------------------------------------------------------------------------
/xdocs/index.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
20 | ]>
21 |
22 |
23 | &project;
24 |
25 |
26 | Jean-Frederic Clere
27 | Documentation Index
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | The Apache Tomcat Native Library is an optional component for use with
36 | Apache Tomcat that allows Tomcat to use OpenSSL as a replacement for JSSE
37 | to support TLS connections.
38 |
84 | On all POSIX-like systems (Linux, Solaris, HP-UX, AIX etc...), the well-known
85 | configure and make are used to build TC-Native.
86 | To see a description of all configuration parameters, run the following command in the native directory of the source distribution:
87 |
88 | ./configure --help
89 |
To create the includes and makefiles necessary for building TC-Native, use the following command:
96 | Where:
97 | $HOME/APR is the path to the APR installation, such as /usr/bin/apr-1-config.
98 | $JAVA_HOME is the path to a JDK installation, for example, /home/jfclere/JAVA/jdk11.
99 | Any JDK version should work, but it is advisable to use the same JVM version as the one you use with Tomcat.
100 | $HOME/OPENSSL is the path where OpenSSL is installed.
101 | $CATALINA_HOME is the path where the produced libraries will be
102 | installed, such as $HOME/apache-tomcat-10.1.0
103 |
104 | The configure script can automatically detect most standard APR and OpenSSL installations. Therefore, an equivalent command is usually sufficient:
105 |
109 | To build and install the libraries, run:
110 |
111 | make && make install
112 |
113 | The libraries will be installed in $CATALINA_HOME/lib.
114 |
115 |
116 |
117 |
118 |
119 | Detailed building instructions including the steps to create a standard release
120 | distribution are provided on the Wiki.
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | Apache Tomcat comes with the AprLifecycleListener enabled
131 | by default. However, it is recommended to check conf/server.xml file
132 | to ensure that the following configuration is present and uncommented:
133 |
134 |
135 | ]]>
137 |
138 | For detailed configuration instructions, please refer to the Apache Tomcat documentation (See
139 | Tomcat 11.0.x,
140 | Tomcat 10.1.x and
141 | Tomcat 9.0.x).
142 |
143 |
144 |
145 |
146 |
147 |
148 | To ensure the TC-Native libraries are correctly loaded, follow these steps:
149 |
150 |
151 |
Edit the $CATALINA_HOME/bin/setenv.sh file. For detailed instructions, please refer to the RUNNING.txt file of your Apache Tomcat distribution.
152 |
Check that TC-Native libraries exist in $CATALINA_HOME/lib and add the path to the TC-Native libraries to the LD_LIBRARY_PATH:
153 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib export LD_LIBRARY_PATH
154 |
Start Tomcat and look for messages similar to the following in the logs:
155 | 21-Jun-2024 11:06:23.274 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [2.0.7] using APR version [1.7.3]. 21-Jun-2024 11:06:23.298 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.2.1 30 Jan 2024]
157 |
158 |
159 |
160 | For detailed configuration of connectors, refer to the Apache Tomcat documentation (See
161 | Tomcat 11.0.x,
162 | Tomcat 10.1.x and
163 | Tomcat 9.0.x).
164 |
165 |
166 |
167 |
168 |
169 | To ensure the TC-Native libraries are correctly loaded, follow these steps:
170 |
171 |
172 |
Edit the $CATALINA_HOME/bin/setenv.sh file. For detailed instructions, please refer to the RUNNING.txt file of your Apache Tomcat distribution.
173 |
Ensure that the tcnative-2.dll file matches CPU architecture of JVM that you use to run Tomcat (x86 or x64) and is located in the $CATALINA_HOME/bin directory.
174 | Alternatively, you can add the path to the TC-Native libraries to the PATH environment variable:
175 | set PATH=%PATH%;C:\your\path\to\tc-native-dll
177 |
Start Tomcat and look for messages similar to the following in the logs:
178 | 21-Jun-2024 11:06:23.274 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [2.0.7] using APR version [1.7.3]. 21-Jun-2024 11:06:23.298 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.2.1 30 Jan 2024]
30 | This is the Changelog for Apache Tomcat Native 2.0.x. The Tomcat Native 2.0.x
31 | branch started from the 1.2.33 tag.
32 |
33 |
34 |
35 |
36 |
37 | Update the Windows build environment to use Visual Studio 2022. (markt)
38 |
39 |
40 | Update the recommended minimum version of OpenSSL to 3.5.0. (markt)
41 |
42 |
43 | Update the recommended minimum version of APR to 1.7.6. (markt)
44 |
45 |
46 |
47 |
48 |
49 |
50 | Fix a crash on Windows when SSLContext.setCACertificate()
51 | is invoked with a null value for caCertificateFile
52 | and a non-null value for caCertificatePath
53 | until properly addressed with
54 | https://github.com/openssl/openssl/issues/24416. (michaelo)
55 |
56 |
57 | Use ERR_error_string_n with a definite buffer length as a named constant.
58 | (schultz)
59 |
60 |
61 | Ensure local reference capacity is available when creating new arrays
62 | and Strings. (schultz)
63 |
64 |
65 | Update the recommended minimum version of OpenSSL to 3.0.14. (markt)
66 |
67 |
68 |
69 |
70 |
71 |
72 | 67538: Make use of Ant's <javaversion />
73 | task to enforce the mininum Java build version. (michaelo)
74 |
75 |
76 | 67615: Windows binary for version 2 has incorrect version
77 | suffix compared to the GNU autoconf version. (michaelo)
78 |
79 |
80 | Align default pass phrase prompt with HTTPd on Windows as well. (michaelo)
81 |
82 |
83 | 67616: o.a.tomcat.jni.SSL contains useless check for old
84 | OpenSSL version. (michaelo)
85 |
86 |
87 | Drop useless compile.optimize option. (michaelo)
88 |
89 |
90 | Align Java source compile configuration with Tomcat. (michaelo)
91 |
92 |
93 | Add Ant version (1.10.2) requirement identical to Tomcat. (michaelo)
94 |
95 |
96 | Remove an unreachable if condition around CRLs in sslcontext.c. (michaelo)
97 |
98 |
99 | 67818: When calling SSL.setVerify() or
100 | SSLContext.setVerify(), the default verify paths are no
101 | longer set. Only the explicitly configured trust store, if any, will be
102 | used. (michaelo)
103 |
104 |
105 | Update the recommended minimum version of OpenSSL to 3.0.13. (markt)
106 |
107 |
108 |
109 |
110 |
111 |
112 | 67061: If the insecure optionalNoCA certificate verification
113 | mode is used, disable OCSP if enabled else client certificates from
114 | unknown certificate authorities will be rejected. (markt)
115 |
116 |
117 | Update the recommended minimum version of OpenSSL to 3.0.11. (markt)
118 |
119 |
120 |
121 |
122 |
123 |
124 | 66666: Remove non-reachable functions from ssl.c. (michaelo)
125 |
126 |
127 | Align default pass phrase prompt with HTTPd. (michaelo)
128 |
129 |
130 | Rename configure.in to modern autotools style configure.ac. (rjung)
131 |
132 |
133 | Fix incomplete updates for autotools generated files during "buildconf" execution. (rjung)
134 |
135 |
136 | Improve quoting in tcnative.m4. (rjung)
137 |
138 |
139 | Update the minimum version of autoconf for releasing to 2.68. (rjung)
140 |
141 |
142 | 66669: Fix memory leak in SNI processing. (markt)
143 |
144 |
145 | Update the recommended minimum version of OpenSSL to 3.0.10. (markt)
146 |
147 |
148 |
149 |
150 |
151 |
152 | Update the recommended minimum version of APR to 1.7.4. (markt)
153 |
154 |
155 | Update the recommended minimum version of OpenSSL to 3.0.9. (markt)
156 |
157 |
158 |
159 |
160 |
161 |
162 | Update the recommended minimum version of APR to 1.7.2. (markt)
163 |
164 |
165 | Update the recommended minimum version of OpenSSL to 3.0.8. (markt)
166 |
167 |
168 |
169 |
170 |
171 |
172 | Update the minimum supported version of LibreSSL to 3.5.2. Based on pull
173 | request 13 provided by orbea. (markt)
174 |
175 |
176 | Fix build when building with rlibtool. Pull request 14 provided
177 | by orbea. (markt)
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 | Update recommended OpenSSL version to 3.0.5 or later. (markt)
186 |
187 |
188 |
189 |
190 |
191 |
192 | Update the minimum required version of OpenSSL to 3.0.0 and make it a
193 | madatory dependency. (markt)
194 |
195 |
196 | Update the minimum required version of APR to 1.7.0. (markt)
197 |
198 |
199 | Remove NPN support as NPN was never standardised and browser support was
200 | removed in 2019. (markt)
201 |
202 |
203 | Add support for using OpenSSL when the FIPS provider is configured as the
204 | default provider. (markt)
205 |
206 |
207 | Remove all API methods (and supporting code) that are not used by Tomcat
208 | 10.1.x to support the use of OpenSSL as a replacement for JSSE to provide
209 | TLS functionality. (markt)
210 |
211 |
212 | Document the TLS rengotiation behaviour. (markt)
213 |
214 |
215 | Update the minimum required Java version to Java 11. (markt)
216 |
217 |
218 | Remove support for Windows 2000, Windows XP, Windows Server 2003, Windows
219 | Vista and Windows Server 2008. The minimum Windows version is now Windows
220 | 7 / Windows Server 2008 R2. (markt)
221 |
222 |
223 | Add HOWTO-RELEASE.txt that describes the release process. (markt)
224 |
225 |
226 | Fix the autoconf warnings when creating a release. (markt)
227 |
228 |
229 |
230 |
231 |
30 | Historically there have been security issues associated with TLS
31 | renegotiation. This page describes the renegotiation behaviour of the Tomcat
32 | Native library.
33 |
34 |
35 |
36 |
37 | Client initiated renegotiation is disabled. This behaviour is hard-coded and
38 | cannot be changed.
39 |
40 |
41 |
42 |
43 | Support for unsafe legacy negotiation depends on OpenSSL. Unsafe legacy
44 | renegotiation is disabled by default and will not be allowed unless the
45 | OpenSSL configuration option
46 | SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION is set.
47 |
The Apache Tomcat team is proud to announce the immediate
35 | availability of Tomcat Native 2.0.2.
36 |
37 |
38 |
39 |
The Apache Tomcat team is proud to announce the immediate
40 | availability of Tomcat Native 2.0.1. This is the first release of the
41 | 2.0.x branch.