Build script updates
parent
194db8317f
commit
ed66804477
|
|
@ -38,3 +38,6 @@ infer-out/
|
|||
target/
|
||||
|
||||
**/.claude/settings.local.json
|
||||
|
||||
# Native dependency files
|
||||
native/*.d
|
||||
|
|
|
|||
141
Makefile
141
Makefile
|
|
@ -17,45 +17,138 @@ ifeq ($(LIBDIR),)
|
|||
LIBDIR=lib
|
||||
endif
|
||||
|
||||
# Native JNI compilation variables
|
||||
NATIVE_SRC_DIR = native
|
||||
NATIVE_SRCS = $(wildcard $(NATIVE_SRC_DIR)/*.c)
|
||||
NATIVE_OBJS = $(NATIVE_SRCS:.c=.o)
|
||||
NATIVE_DEPS = $(NATIVE_SRCS:.c=.d)
|
||||
|
||||
CC ?= gcc
|
||||
WOLFSSL_INSTALL_DIR ?= $(INSTALL_DIR)
|
||||
WOLFSSL_LIBNAME ?= wolfssl
|
||||
|
||||
# Platform detection
|
||||
OS := $(shell uname)
|
||||
ARCH := $(shell uname -m)
|
||||
|
||||
# JAVA_HOME detection with platform-aware fallback
|
||||
JAVA_HOME ?= $(shell \
|
||||
if [ "$(OS)" = "Darwin" ]; then \
|
||||
/usr/libexec/java_home 2>/dev/null; \
|
||||
else \
|
||||
java_bin=$$(readlink -f $$(which java) 2>/dev/null); \
|
||||
jh=$$(dirname $$(dirname $$java_bin)); \
|
||||
if [ ! -d "$$jh/include" ]; then jh=$$(dirname $$jh); fi; \
|
||||
echo $$jh; \
|
||||
fi)
|
||||
|
||||
# Platform-specific flags
|
||||
ifeq ($(OS),Darwin)
|
||||
JNI_INCLUDES = -I$(JAVA_HOME)/include \
|
||||
-I$(JAVA_HOME)/include/darwin \
|
||||
-I$(WOLFSSL_INSTALL_DIR)/include
|
||||
JNI_LIB_FLAGS = -dynamiclib
|
||||
JNI_LIB_NAME = libwolfssljni.dylib
|
||||
else ifeq ($(OS),Linux)
|
||||
JNI_INCLUDES = -I$(JAVA_HOME)/include \
|
||||
-I$(JAVA_HOME)/include/linux \
|
||||
-I$(WOLFSSL_INSTALL_DIR)/include
|
||||
JNI_LIB_FLAGS = -shared
|
||||
JNI_LIB_NAME = libwolfssljni.so
|
||||
ifneq ($(filter x86_64 aarch64,$(ARCH)),)
|
||||
FPIC = -fPIC
|
||||
endif
|
||||
else
|
||||
$(error Unsupported host OS '$(OS)'; supported OSes are Linux and Darwin)
|
||||
endif
|
||||
|
||||
# Optionally enable all patch defines in the native code for testing.
|
||||
ifeq ($(ENABLE_PATCHES),1)
|
||||
PATCH_CFLAGS = $(addprefix -D,$(shell ./scripts/find-wolfssl-pr-patch-defines.sh))
|
||||
ifeq ($(PATCH_CFLAGS),)
|
||||
$(warning no WOLFSSL_PR*_PATCH_APPLIED defines found; building without patches)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Verbose mode: set V=1 to see full compiler commands
|
||||
ifeq ($(V),1)
|
||||
Q =
|
||||
else
|
||||
Q = @
|
||||
endif
|
||||
|
||||
JNI_CFLAGS = -Wall -Wextra -Werror $(FPIC) -MMD -MP $(PATCH_CFLAGS) $(CFLAGS)
|
||||
JNI_LDFLAGS = -Wall $(JNI_LIB_FLAGS) $(CFLAGS) \
|
||||
-L$(WOLFSSL_INSTALL_DIR)/lib \
|
||||
-L$(WOLFSSL_INSTALL_DIR)/lib64
|
||||
JNI_LDLIBS = -l$(WOLFSSL_LIBNAME)
|
||||
|
||||
.PHONY: all build check native clean-native clean install uninstall dist rpm print-config
|
||||
|
||||
all: build
|
||||
|
||||
.PHONY: build
|
||||
build: java.sh build.xml
|
||||
@cflags=""; \
|
||||
if [ "$(ENABLE_PATCHES)" = "1" ]; then \
|
||||
if [ -n "$(PATCH_DEFINES)" ]; then \
|
||||
defines="$(PATCH_DEFINES)"; \
|
||||
else \
|
||||
defines="$$(./scripts/find-wolfssl-pr-patch-defines.sh)"; \
|
||||
fi; \
|
||||
if [ -z "$$defines" ]; then \
|
||||
echo "warning: no WOLFSSL_PR*_PATCH_APPLIED defines found; building without patches"; \
|
||||
else \
|
||||
for define in $$defines; do \
|
||||
cflags="$$cflags -D$$define"; \
|
||||
done; \
|
||||
fi; \
|
||||
fi; \
|
||||
CFLAGS="$$cflags" ./java.sh $(INSTALL_DIR); \
|
||||
build: build.xml
|
||||
$(MAKE) native WOLFSSL_INSTALL_DIR="$(WOLFSSL_INSTALL_DIR)" WOLFSSL_LIBNAME="$(WOLFSSL_LIBNAME)"
|
||||
ant
|
||||
|
||||
check: build
|
||||
ant test
|
||||
|
||||
clean:
|
||||
ant clean cleanjni
|
||||
# Pattern rule: compile any native/*.c to native/*.o
|
||||
$(NATIVE_SRC_DIR)/%.o: $(NATIVE_SRC_DIR)/%.c | print-config
|
||||
@echo " CC $<"
|
||||
$(Q)$(CC) $(JNI_CFLAGS) -c $< -o $@ $(JNI_INCLUDES)
|
||||
|
||||
# Link all .o files into the shared library
|
||||
lib/$(JNI_LIB_NAME): $(NATIVE_OBJS) | lib
|
||||
@echo " LD $@"
|
||||
$(Q)$(CC) $(JNI_LDFLAGS) -o $@ $(NATIVE_OBJS) $(JNI_LDLIBS)
|
||||
|
||||
lib:
|
||||
mkdir -p lib
|
||||
|
||||
# Print build configuration, matching the output style of upstream java.sh
|
||||
print-config:
|
||||
@echo "Compiling Native JNI library:"
|
||||
@echo " WOLFSSL_INSTALL_DIR = $(WOLFSSL_INSTALL_DIR)"
|
||||
@echo " WOLFSSL_LIBNAME = $(WOLFSSL_LIBNAME)"
|
||||
@if [ -n "$(JAVA_HOME)" ]; then \
|
||||
echo " JAVA_HOME = $(JAVA_HOME)"; \
|
||||
else \
|
||||
echo " JAVA_HOME = <not set>"; \
|
||||
fi
|
||||
@if [ -n "$(CFLAGS)" ]; then \
|
||||
echo " CFLAGS = $(CFLAGS)"; \
|
||||
else \
|
||||
echo " CFLAGS = <none>"; \
|
||||
fi
|
||||
@echo " Host OS = $(OS) $(ARCH)"
|
||||
|
||||
# Convenience target for building just native JNI library
|
||||
native: lib/$(JNI_LIB_NAME)
|
||||
@echo " Generated ./lib/$(JNI_LIB_NAME)"
|
||||
|
||||
# Clean only native artifacts (.o, .d files and shared lib)
|
||||
clean-native:
|
||||
$(Q)rm -f $(NATIVE_SRC_DIR)/*.o $(NATIVE_SRC_DIR)/*.d
|
||||
$(Q)rm -f lib/$(JNI_LIB_NAME)
|
||||
|
||||
# Include auto-generated dependency files (if they exist)
|
||||
-include $(NATIVE_DEPS)
|
||||
|
||||
clean: clean-native
|
||||
ant clean cleanjni
|
||||
|
||||
install:
|
||||
$(INSTALL) -d $(INSTALL_DIR)/$(LIBDIR)
|
||||
$(INSTALL) lib/libwolfssljni.so $(INSTALL_DIR)/$(LIBDIR)
|
||||
$(INSTALL) lib/$(JNI_LIB_NAME) $(INSTALL_DIR)/$(LIBDIR)
|
||||
$(INSTALL) lib/wolfssl.jar $(INSTALL_DIR)/$(LIBDIR)
|
||||
$(INSTALL) lib/wolfssl-jsse.jar $(INSTALL_DIR)/$(LIBDIR)
|
||||
|
||||
uninstall:
|
||||
rm -f $(INSTALL_DIR)/$(LIBDIR)/libwolfssljni.so
|
||||
rm -f $(INSTALL_DIR)/share/java/wolfssl.jar
|
||||
rm -f $(INSTALL_DIR)/share/java/wolfssl-jsse.jar
|
||||
rm -f $(INSTALL_DIR)/$(LIBDIR)/$(JNI_LIB_NAME)
|
||||
rm -f $(INSTALL_DIR)/$(LIBDIR)/wolfssl.jar
|
||||
rm -f $(INSTALL_DIR)/$(LIBDIR)/wolfssl-jsse.jar
|
||||
|
||||
dist:
|
||||
@mkdir -p "$(NAME)-$(VERSION)"
|
||||
|
|
|
|||
126
README.md
126
README.md
|
|
@ -65,33 +65,65 @@ If building a wolfSSL FIPS or FIPS Ready release bundle, additional
|
|||
configure options may be required. Reference the wolfSSL Manual and build
|
||||
documentation for exact build instructions.
|
||||
|
||||
## Building with ant
|
||||
## Building and testing with make/ant
|
||||
|
||||
wolfSSL JNI/JSSE's ant build is the most stable and well-tested. Newer support
|
||||
for building with Maven has also been added. See section below for instructions
|
||||
on building with Maven.
|
||||
|
||||
***Note 1)***
|
||||
The `java.sh` script uses a common location for the Java install location. If
|
||||
your Java install location is different, this could lead to an error when
|
||||
running `java.sh`. In this case, you should modify `java.sh` to match your
|
||||
environment.
|
||||
The `Makefile` compiles the native JNI shared library
|
||||
(`libwolfssljni.so`/`libwolfssljni.dylib`) and invokes `ant` to build the Java
|
||||
sources. It will auto-detect `JAVA_HOME` if not already set. To explicitly
|
||||
specify a Java installation, set `JAVA_HOME` before running `make`.
|
||||
|
||||
Build targets for ant are :
|
||||
* **ant build (ant)** (only builds the jar necessary for an app to use)
|
||||
* **ant test** (builds the jar and tests then runs the tests, requires JUNIT setup)
|
||||
* **ant examples** (builds the jar and example cases)
|
||||
* **ant clean** (cleans all Java artifacts)
|
||||
* **ant cleanjni** (cleans native artifacts)
|
||||
Make targets:
|
||||
* **make** / **make build** - Compiles the native JNI library and Java sources (JAR)
|
||||
* **make check** - Builds and runs JUnit tests (requires `JUNIT_HOME`)
|
||||
* **make native** - Compiles only the native JNI shared library
|
||||
* **make clean** - Cleans all Java and native artifacts
|
||||
* **make clean-native** - Cleans only native artifacts (`.o`, `.d`, shared lib)
|
||||
* **make install** - Installs shared library and JARs
|
||||
* **make uninstall** - Removes installed files
|
||||
|
||||
Ant-only targets are also available:
|
||||
* **ant build (ant)** - Only builds the JAR
|
||||
* **ant test** - Builds and runs tests (requires JUNIT setup)
|
||||
* **ant examples** - Builds examples
|
||||
* **ant clean** - Cleans Java artifacts
|
||||
* **ant cleanjni** - Cleans native artifacts
|
||||
|
||||
To build wolfJSSE:
|
||||
|
||||
```
|
||||
$ cd wolfssljni
|
||||
$ ./java.sh
|
||||
$ ant
|
||||
$ export JUNIT_HOME=/path/to/junit/jars
|
||||
$ ant test
|
||||
$ make build
|
||||
$ make check
|
||||
```
|
||||
|
||||
Custom wolfSSL installation directories and library names can be passed to
|
||||
`make`:
|
||||
|
||||
```
|
||||
$ make WOLFSSL_INSTALL_DIR=/path/to/wolfssl WOLFSSL_LIBNAME=wolfssljsse
|
||||
```
|
||||
|
||||
Set `V=1` to see the full compiler commands:
|
||||
|
||||
```
|
||||
$ make V=1
|
||||
```
|
||||
|
||||
Set `ENABLE_PATCHES=1` to automatically detect and enable JNI code that
|
||||
depends on wolfSSL pull request patches (`WOLFSSL_PR*_PATCH_APPLIED` defines).
|
||||
This enables functionality and test coverage for features added since the last
|
||||
official wolfSSL build.
|
||||
|
||||
**Note:** this requires a recent build of wolfSSL with the PR included, often
|
||||
newer than the latest tagged release.
|
||||
|
||||
```
|
||||
$ make ENABLE_PATCHES=1
|
||||
```
|
||||
|
||||
To compile and run the examples, use the `ant examples` target:
|
||||
|
|
@ -108,28 +140,20 @@ $ ./examples/provider/ServerJSSE.sh
|
|||
$ ./examples/provider/ClientJSSE.sh
|
||||
```
|
||||
|
||||
### java.sh Script Options
|
||||
### java.sh Script
|
||||
|
||||
The `java.sh` script compiles the native JNI sources into a shared library named
|
||||
either `libwolfssljni.so` (Linux/Unix) or `libwolfssljni.dylib` (MacOS).
|
||||
Compiling on Linux/Unix and Mac OSX are currently supported.
|
||||
The `java.sh` script is a convenience wrapper around the Makefile that compiles
|
||||
the native JNI sources into a shared library named either `libwolfssljni.so`
|
||||
(Linux/Unix) or `libwolfssljni.dylib` (MacOS). It invokes `make clean-native`
|
||||
followed by `make native`, performing a clean rebuild of the native library each
|
||||
time.
|
||||
|
||||
This script will attempt to auto-detect the `JAVA_HOME` location if not set.
|
||||
To explicitly use a Java home location, set the `JAVA_HOME` environment variable
|
||||
prior to running this script.
|
||||
The script accepts two optional arguments:
|
||||
|
||||
This script will try to link against a wolfSSL library installed to the
|
||||
default location of `/usr/local`. This script accepts two arguments on the
|
||||
command line. The first argument can point to a custom wolfSSL installation
|
||||
location. A custom install location would match the directory set at wolfSSL
|
||||
`./configure --prefix=<DIR>`.
|
||||
|
||||
The second argument represents the wolfSSL library name that should be
|
||||
linked against. This is helpful if a non-standard library name has been
|
||||
used with wolfSSL, for example the `./configure --with-libsuffix` option
|
||||
has been used to add a suffix to the wolfSSL library name. Note that to
|
||||
use this argument, an installation location must be specified via the
|
||||
first argument.
|
||||
1. **wolfSSL installation directory** (default: `/usr/local`) - should match
|
||||
the directory set at wolfSSL `./configure --prefix=<DIR>`.
|
||||
2. **wolfSSL library name** (default: `wolfssl`) - useful if a non-standard
|
||||
library name has been used, for example via `./configure --with-libsuffix`.
|
||||
|
||||
For example, if wolfSSL was configured with `--with-libsuffix=jsse`, then
|
||||
this script could be called like so using the default installation
|
||||
|
|
@ -139,8 +163,7 @@ path of `/usr/local`:
|
|||
java.sh /usr/local wolfssljsse
|
||||
```
|
||||
|
||||
`java.sh` can use preset `CFLAGS` defines, if set in the environment variable
|
||||
prior to running the script, for example:
|
||||
`CFLAGS` can be set in the environment prior to running the script:
|
||||
|
||||
```
|
||||
CFLAGS=-DWOLFJNI_USE_IO_SELECT java.sh
|
||||
|
|
@ -153,12 +176,11 @@ are already set up to use and consume Maven packages.
|
|||
|
||||
wolfJSSE's Maven build configuration is defined in the included `pom.xml`.
|
||||
|
||||
First, compile the native JNI shared library (libwolfssljni.so/dylib) same
|
||||
as above. This will create the native JNI shared library under the `./lib`
|
||||
directory:
|
||||
First, compile the native JNI shared library (libwolfssljni.so/dylib). This
|
||||
will create the native JNI shared library under the `./lib` directory:
|
||||
|
||||
```
|
||||
$ ./java.sh
|
||||
$ make native
|
||||
```
|
||||
|
||||
Compile the Java sources, where Maven will place the compiled `.class` files
|
||||
|
|
@ -202,10 +224,10 @@ The local Maven repository installation location will be similar to:
|
|||
~/.m2/repository/com/wolfssl/wolfssl-jsse/X.X.X-SNAPSHOT/wolfssl-jsse-X.X.X-SNAPSHOT.jar
|
||||
```
|
||||
|
||||
The wolfSSL JNI shared library (`libwolfssljni.so/dylib`) created with the
|
||||
`java.sh` script will need to be "installed" by being placed on your native
|
||||
The wolfSSL JNI shared library (`libwolfssljni.so/dylib`) will need to be
|
||||
"installed" by being placed on your native
|
||||
library search path. For example, copied into `/usr/local/lib`, `/usr/lib`,
|
||||
or other location. Alternatively, append the `./libs` directory to your native
|
||||
or other location. Alternatively, append the `./lib` directory to your native
|
||||
library search path by exporting `LD_LIBRARY_PATH` (Linux) or
|
||||
`DYLD_LIBRARY_PATH` (OSX):
|
||||
|
||||
|
|
@ -261,15 +283,14 @@ Maven builds support automatic module-info compilation.
|
|||
|
||||
```
|
||||
$ export JAVA_HOME=/path/to/jdk11 # or any JDK 9+
|
||||
$ ./java.sh
|
||||
$ ant
|
||||
$ make build
|
||||
```
|
||||
|
||||
**Using Maven:**
|
||||
|
||||
```
|
||||
$ export JAVA_HOME=/path/to/jdk11 # or any JDK 9+
|
||||
$ ./java.sh
|
||||
$ make native
|
||||
$ mvn package
|
||||
```
|
||||
|
||||
|
|
@ -494,7 +515,8 @@ file descriptors inside Java Socket objects. These native file descriptors
|
|||
are watched for read and write events with either `select()` or `poll()`.
|
||||
|
||||
By default `poll()` will be used, unless `WOLFJNI_USE_IO_SELECT` is defined
|
||||
or added to CFLAGS when compiling the native JNI sources (see `java.sh`).
|
||||
or added to CFLAGS when compiling the native JNI sources (e.g.
|
||||
`make CFLAGS=-DWOLFJNI_USE_IO_SELECT`).
|
||||
Windows builds will also default to using `select()` since `poll()` is not
|
||||
available there.
|
||||
|
||||
|
|
@ -698,14 +720,14 @@ legacy behavior where SNI is automatically configured from hostname/peer informa
|
|||
even without explicit SSLParameters configuration. Default value is "false", where
|
||||
SNI is only set when explicitly configured through SSLParameters.
|
||||
|
||||
**wolfssl.skipLibraryLoad (boolean)** - When set to "true", `WolfSSL.loadLibrary()`
|
||||
**wolfssl.skipLibraryLoad (boolean)** - When set to "true", `wolfSSL.loadLibrary()`
|
||||
will skip the default `System.loadLibrary()` calls for native wolfSSL and
|
||||
wolfSSL JNI libraries. This is useful when applications need to load the native
|
||||
libraries themselves using custom logic, for example when bundling the native
|
||||
library inside a JAR file and extracting it at runtime. The property must be set
|
||||
before `WolfSSL.loadLibrary()` is called, either directly or via
|
||||
before `wolfSSL.loadLibrary()` is called, either directly or via
|
||||
`WolfSSLProvider()` constructor. Applications can check if library loading was
|
||||
skipped by calling `WolfSSL.isLibraryLoadSkipped()`.
|
||||
skipped by calling `wolfSSL.isLibraryLoadSkipped()`.
|
||||
|
||||
Setting via command line:
|
||||
|
||||
|
|
@ -722,8 +744,8 @@ System.setProperty("wolfssl.skipLibraryLoad", "true");
|
|||
System.load("/path/to/libwolfssl.so");
|
||||
System.load("/path/to/libwolfssljni.so");
|
||||
|
||||
/* Then use WolfSSL as normal */
|
||||
WolfSSL.loadLibrary();
|
||||
/* Then use wolfSSL as normal */
|
||||
wolfSSL.loadLibrary();
|
||||
```
|
||||
|
||||
If there are other System properties you would like to use with wolfJSSE,
|
||||
|
|
|
|||
112
java.sh
112
java.sh
|
|
@ -3,12 +3,12 @@
|
|||
# Native JNI shared library compilation script
|
||||
#
|
||||
# This script compiles the native JNI sources into a shared library named
|
||||
# either libwolfssljni.so/.dylib. Compiling on Linux/Unix and Mac OSX are
|
||||
# currently supported.
|
||||
# either libwolfssljni.so/.dylib by invoking the Makefile native target.
|
||||
# Compiling on Linux/Unix and Mac OSX are currently supported.
|
||||
#
|
||||
# This script will attempt to auto-detect JAVA_HOME location if not set. To
|
||||
# explicitly use a Java home location, set the JAVA_HOME environment variable
|
||||
# prior to running this script.
|
||||
# JAVA_HOME detection is handled by the Makefile. To explicitly use a Java
|
||||
# home location, set the JAVA_HOME environment variable prior to running
|
||||
# this script.
|
||||
#
|
||||
# This script will try to link against a wolfSSL library installed to the
|
||||
# default location of /usr/local. This script accepts two arguments on the
|
||||
|
|
@ -32,9 +32,6 @@
|
|||
# Fail on any errors
|
||||
set -euo pipefail
|
||||
|
||||
OS=`uname`
|
||||
ARCH=`uname -m`
|
||||
|
||||
if [ -z "${1-}" ]; then
|
||||
# default install location is /usr/local
|
||||
WOLFSSL_INSTALL_DIR="/usr/local"
|
||||
|
|
@ -55,98 +52,9 @@ fi
|
|||
|
||||
echo "Compiling Native JNI library:"
|
||||
echo " WOLFSSL_INSTALL_DIR = $WOLFSSL_INSTALL_DIR"
|
||||
echo " WOLFSSL_LIBNAME = $WOLFSSL_LIBNAME"
|
||||
|
||||
if [ -z "${JAVA_HOME:-}" ]; then
|
||||
# if JAVA_HOME not set, detect based on platform/OS
|
||||
echo " JAVA_HOME empty, trying to detect"
|
||||
else
|
||||
# user already set JAVA_HOME, use that
|
||||
echo " JAVA_HOME already set = $JAVA_HOME"
|
||||
javaHome="$JAVA_HOME"
|
||||
fi
|
||||
|
||||
if [ -z "${CFLAGS:-}" ]; then
|
||||
echo " CFLAGS = <none>"
|
||||
else
|
||||
echo " CFLAGS = $CFLAGS"
|
||||
fi
|
||||
|
||||
fpic=""
|
||||
CFLAGS="${CFLAGS:-}"
|
||||
|
||||
# set up Java include and library paths for OS X and Linux
|
||||
# NOTE: you may need to modify these if your platform uses different locations
|
||||
if [ "$OS" == "Darwin" ] ; then
|
||||
echo " Detected Darwin/OSX host OS"
|
||||
if [ -z "${javaHome:-}" ]; then
|
||||
# this is broken since Big Sur, set JAVA_HOME environment var instead
|
||||
# OSX JAVA_HOME is typically similar to:
|
||||
# /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home
|
||||
javaHome=`/usr/libexec/java_home`
|
||||
fi
|
||||
javaIncludes="-I$javaHome/include -I$javaHome/include/darwin -I$WOLFSSL_INSTALL_DIR/include"
|
||||
javaLibs="-dynamiclib"
|
||||
jniLibName="libwolfssljni.dylib"
|
||||
elif [ "$OS" == "Linux" ] ; then
|
||||
echo " Detected Linux host OS"
|
||||
if [ -z "${javaHome:-}" ]; then
|
||||
javaHome=`echo $(dirname $(dirname $(readlink -f $(which java))))`
|
||||
fi
|
||||
if [ ! -d "$javaHome/include" ]
|
||||
then
|
||||
javaHome=`echo $(dirname $javaHome)`
|
||||
fi
|
||||
javaIncludes="-I$javaHome/include -I$javaHome/include/linux -I$WOLFSSL_INSTALL_DIR/include"
|
||||
javaLibs="-shared"
|
||||
jniLibName="libwolfssljni.so"
|
||||
if [ "$ARCH" == "x86_64" ] || [ "$ARCH" == "aarch64" ]; then
|
||||
fpic="-fPIC"
|
||||
fi
|
||||
else
|
||||
echo 'Unknown host OS!'
|
||||
exit
|
||||
fi
|
||||
echo " $OS $ARCH"
|
||||
|
||||
echo " Java Home = $javaHome"
|
||||
|
||||
# create /lib directory if doesn't exist
|
||||
if [ ! -d ./lib ]
|
||||
then
|
||||
mkdir ./lib
|
||||
fi
|
||||
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSL.c -o ./native/com_wolfssl_WolfSSL.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSLSession.c -o ./native/com_wolfssl_WolfSSLSession.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSLContext.c -o ./native/com_wolfssl_WolfSSLContext.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfCryptRSA.c -o ./native/com_wolfssl_WolfCryptRSA.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfCryptECC.c -o ./native/com_wolfssl_WolfCryptECC.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfCryptEccKey.c -o ./native/com_wolfssl_WolfCryptEccKey.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSLCertManager.c -o ./native/com_wolfssl_WolfSSLCertManager.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSLCertRequest.c -o ./native/com_wolfssl_WolfSSLCertRequest.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSLCertificate.c -o ./native/com_wolfssl_WolfSSLCertificate.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSLCRL.c -o ./native/com_wolfssl_WolfSSLCRL.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSLX509Name.c -o ./native/com_wolfssl_WolfSSLX509Name.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSLX509StoreCtx.c -o ./native/com_wolfssl_WolfSSLX509StoreCtx.o $javaIncludes
|
||||
gcc -Wall -c $fpic $CFLAGS ./native/com_wolfssl_WolfSSLNameConstraints.c -o ./native/com_wolfssl_WolfSSLNameConstraints.o $javaIncludes
|
||||
gcc -Wall $javaLibs $CFLAGS -o ./lib/$jniLibName \
|
||||
./native/com_wolfssl_WolfSSL.o \
|
||||
./native/com_wolfssl_WolfSSLSession.o \
|
||||
./native/com_wolfssl_WolfSSLContext.o \
|
||||
./native/com_wolfssl_WolfCryptRSA.o \
|
||||
./native/com_wolfssl_WolfCryptECC.o \
|
||||
./native/com_wolfssl_WolfCryptEccKey.o \
|
||||
./native/com_wolfssl_WolfSSLCertManager.o \
|
||||
./native/com_wolfssl_WolfSSLCertRequest.o \
|
||||
./native/com_wolfssl_WolfSSLCertificate.o \
|
||||
./native/com_wolfssl_WolfSSLCRL.o \
|
||||
./native/com_wolfssl_WolfSSLX509Name.o \
|
||||
./native/com_wolfssl_WolfSSLX509StoreCtx.o \
|
||||
./native/com_wolfssl_WolfSSLNameConstraints.o \
|
||||
-L$WOLFSSL_INSTALL_DIR/lib -L$WOLFSSL_INSTALL_DIR/lib64 -l$WOLFSSL_LIBNAME
|
||||
if [ $? != 0 ]; then
|
||||
echo "Error creating native JNI library"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " Generated ./lib/$jniLibName"
|
||||
# Do a clean build of the native library to preserve legacy script behavior.
|
||||
make clean-native native \
|
||||
WOLFSSL_INSTALL_DIR="$WOLFSSL_INSTALL_DIR" \
|
||||
WOLFSSL_LIBNAME="$WOLFSSL_LIBNAME"
|
||||
|
|
|
|||
|
|
@ -216,6 +216,8 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved)
|
|||
{
|
||||
JNIEnv* env;
|
||||
|
||||
(void)reserved;
|
||||
|
||||
if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1830,6 +1832,7 @@ JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getWolfCryptFIPSCoreHash
|
|||
(JNIEnv* jenv, jclass jcl)
|
||||
{
|
||||
#ifdef HAVE_FIPS
|
||||
(void)jcl;
|
||||
return (*jenv)->NewStringUTF(jenv, wolfCrypt_GetCoreHash_fips());
|
||||
#else
|
||||
(void)jenv;
|
||||
|
|
@ -2025,6 +2028,9 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSL_getHmacMaxSize
|
|||
JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSL_getLibVersionHex
|
||||
(JNIEnv* jenv, jclass jcl)
|
||||
{
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
|
||||
return (jlong)wolfSSL_lib_version_hex();
|
||||
}
|
||||
|
||||
|
|
@ -2273,6 +2279,10 @@ int DefaultNativeCryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
|
|||
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSL_wc_1CryptoCb_1RegisterDevice
|
||||
(JNIEnv* jenv, jclass jcl, jint devId)
|
||||
{
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
(void)devId;
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
|
||||
/* WOLFSSLJNI_USE_NATIVE_CRYPTOCB callback is mutually exclusive of other
|
||||
|
|
@ -2304,9 +2314,6 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSL_wc_1CryptoCb_1RegisterDevice
|
|||
#endif
|
||||
#else
|
||||
/* no-op if crypto callbacks not compiled into native wolfSSL */
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
(void)devId;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -2314,13 +2321,14 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSL_wc_1CryptoCb_1RegisterDevice
|
|||
JNIEXPORT void JNICALL Java_com_wolfssl_WolfSSL_wc_1CryptoCb_1UnRegisterDevice
|
||||
(JNIEnv* jenv, jclass jcl, jint devId)
|
||||
{
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
(void)devId;
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
wc_CryptoCb_UnRegisterDevice((int)devId);
|
||||
#else
|
||||
/* no-op if crypto callbacks not compiled into native wolfSSL */
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
(void)devId;
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -2608,6 +2616,9 @@ JNIEXPORT jobjectArray JNICALL Java_com_wolfssl_WolfSSL_getProtocolsMask
|
|||
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSL_getErrno
|
||||
(JNIEnv* jenv, jclass jcl)
|
||||
{
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
|
||||
#ifndef USE_WINDOWS_API
|
||||
return errno;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -370,6 +370,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLCertRequest_X509_1REQ_1set_1pubke
|
|||
unsigned char* rsaPubBuf = NULL;
|
||||
int ret = WOLFSSL_SUCCESS;
|
||||
(void)jcl;
|
||||
(void)keyType;
|
||||
|
||||
if (jenv == NULL || x509 == NULL) {
|
||||
return WOLFSSL_FAILURE;
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLCertificate_X509_1set_1pubkey_1na
|
|||
|
||||
int ret = WOLFSSL_SUCCESS;
|
||||
(void)jcl;
|
||||
(void)keyType;
|
||||
|
||||
if (jenv == NULL || x509 == NULL) {
|
||||
return WOLFSSL_FAILURE;
|
||||
|
|
@ -1590,6 +1591,8 @@ JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSLCertificate_X509_1get_1issuer_1n
|
|||
WOLFSSL_X509* x509 = (WOLFSSL_X509*)(uintptr_t)x509Ptr;
|
||||
WOLFSSL_X509_NAME* name = NULL;
|
||||
|
||||
(void)jcl;
|
||||
|
||||
if (jenv == NULL || x509 == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2120,8 +2123,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_wolfssl_WolfSSLCertificate_X509_1get_1ex
|
|||
EKU_EMAILPROTECT_OID);
|
||||
idx = addEkuOid(jenv, ret, idx, ekuBits, XKU_TIMESTAMP,
|
||||
EKU_TIMESTAMP_OID);
|
||||
idx = addEkuOid(jenv, ret, idx, ekuBits, XKU_OCSP_SIGN,
|
||||
EKU_OCSP_SIGN_OID);
|
||||
(void)addEkuOid(jenv, ret, idx, ekuBits, XKU_OCSP_SIGN, EKU_OCSP_SIGN_OID);
|
||||
|
||||
(*jenv)->DeleteLocalRef(jenv, stringClass);
|
||||
|
||||
|
|
|
|||
|
|
@ -2811,7 +2811,7 @@ JNIEXPORT void JNICALL Java_com_wolfssl_WolfSSLContext_setEccSignCb
|
|||
}
|
||||
|
||||
#if defined(HAVE_PK_CALLBACKS) && defined(HAVE_ECC)
|
||||
if(ctx) {
|
||||
if (ctx) {
|
||||
/* set ECC sign callback */
|
||||
wolfSSL_CTX_SetEccSignCb((WOLFSSL_CTX*)(uintptr_t)ctx, NativeEccSignCb);
|
||||
|
||||
|
|
@ -2821,7 +2821,8 @@ JNIEXPORT void JNICALL Java_com_wolfssl_WolfSSLContext_setEccSignCb
|
|||
"EccSignCb");
|
||||
}
|
||||
#else
|
||||
(*jenv)->ThrowNew(jenv, excClass,
|
||||
(void)ctx;
|
||||
(*jenv)->ThrowNew(jenv, excClass,
|
||||
"wolfSSL not compiled with PK Callback support "
|
||||
"(HAVE_PK_CALLBACKS)");
|
||||
#endif
|
||||
|
|
@ -3114,7 +3115,7 @@ JNIEXPORT void JNICALL Java_com_wolfssl_WolfSSLContext_setEccVerifyCb
|
|||
}
|
||||
|
||||
#if defined(HAVE_PK_CALLBACKS) && defined(HAVE_ECC)
|
||||
if(ctx) {
|
||||
if (ctx) {
|
||||
/* set ECC verify callback */
|
||||
wolfSSL_CTX_SetEccVerifyCb((WOLFSSL_CTX*)(uintptr_t)ctx,
|
||||
NativeEccVerifyCb);
|
||||
|
|
@ -3125,6 +3126,7 @@ JNIEXPORT void JNICALL Java_com_wolfssl_WolfSSLContext_setEccVerifyCb
|
|||
"EccVerifyCb");
|
||||
}
|
||||
#else
|
||||
(void)ctx;
|
||||
(*jenv)->ThrowNew(jenv, excClass,
|
||||
"wolfSSL not compiled with PK Callback support "
|
||||
"(HAVE_PK_CALLBACKS)");
|
||||
|
|
@ -5923,6 +5925,7 @@ void JNICALL Java_com_wolfssl_WolfSSLContext_flushSessions
|
|||
(JNIEnv* jenv, jobject jcl, jlong ctxPtr, jint tm)
|
||||
{
|
||||
WOLFSSL_CTX* ctx = (WOLFSSL_CTX*)(uintptr_t)ctxPtr;
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
|
||||
wolfSSL_CTX_flush_sessions(ctx, (int)tm);
|
||||
|
|
|
|||
|
|
@ -1252,7 +1252,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_write__JLjava_nio_ByteBuf
|
|||
(JNIEnv* jenv, jobject jcl, jlong sslPtr, jobject buf, jint position,
|
||||
jint limit, jboolean hasArray, jint length, jint timeout)
|
||||
{
|
||||
int ret;
|
||||
int ret = BAD_FUNC_ARG;
|
||||
int maxInputSz;
|
||||
int inSz = length;
|
||||
byte* data = NULL;
|
||||
|
|
@ -1557,6 +1557,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_pending
|
|||
(JNIEnv* jenv, jobject jcl, jlong sslPtr)
|
||||
{
|
||||
WOLFSSL* ssl = (WOLFSSL*)(uintptr_t)sslPtr;
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
|
||||
/* Checks ssl for NULL internally, will return WOLFSSL_FAILURE */
|
||||
|
|
@ -2338,6 +2339,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_setServerID
|
|||
int idBufSz = 0;
|
||||
WOLFSSL* ssl = (WOLFSSL*)(uintptr_t)sslPtr;
|
||||
(void)jcl;
|
||||
(void)len;
|
||||
|
||||
if (jenv == NULL || ssl == NULL || id == NULL) {
|
||||
return WOLFSSL_FAILURE;
|
||||
|
|
@ -2759,6 +2761,10 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_sendHrrCookie
|
|||
JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSLSession_getDtlsMacDropCount
|
||||
(JNIEnv* jenv, jobject jcl, jlong sslPtr)
|
||||
{
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
(void)sslPtr;
|
||||
|
||||
word32 dropCount = 0;
|
||||
#if defined(WOLFSSL_DTLS) && defined(WOLFSSL_DTLS_DROP_STATS)
|
||||
int ret = 0;
|
||||
|
|
@ -2770,15 +2776,16 @@ JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSLSession_getDtlsMacDropCount
|
|||
return (jlong)ret;
|
||||
}
|
||||
#endif
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
|
||||
return (jlong)dropCount;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSLSession_getDtlsReplayDropCount
|
||||
(JNIEnv* jenv, jobject jcl, jlong sslPtr)
|
||||
{
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
(void)sslPtr;
|
||||
|
||||
word32 dropCount = 0;
|
||||
#if defined(WOLFSSL_DTLS) && defined(WOLFSSL_DTLS_DROP_STATS)
|
||||
int ret = 0;
|
||||
|
|
@ -2790,9 +2797,6 @@ JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSLSession_getDtlsReplayDropCount
|
|||
return (jlong)ret;
|
||||
}
|
||||
#endif
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
|
||||
return (jlong)dropCount;
|
||||
}
|
||||
|
||||
|
|
@ -3202,6 +3206,8 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_setMTU
|
|||
{
|
||||
#if defined(WOLFSSL_DTLS) && defined(WOLFSSL_DTLS_MTU)
|
||||
WOLFSSL* ssl = (WOLFSSL*)(uintptr_t)sslPtr;
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
|
||||
/* wolfSSL_dtls_set_mtu() checks ssl for NULL */
|
||||
return (jint)wolfSSL_dtls_set_mtu(ssl, (unsigned short)mtu);
|
||||
|
|
@ -3248,6 +3254,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_getMaxOutputSize
|
|||
#ifndef NO_TLS
|
||||
int ret;
|
||||
WOLFSSL* ssl = (WOLFSSL*)(uintptr_t)sslPtr;
|
||||
(void)jcl;
|
||||
|
||||
if (jenv == NULL || ssl == NULL) {
|
||||
return 0;
|
||||
|
|
@ -5597,6 +5604,7 @@ int NativeALPNSelectCb(WOLFSSL *ssl, const unsigned char **out,
|
|||
int peerProtoCount = 0;
|
||||
char* peerProtos = NULL;
|
||||
char* peerProtosCopy = NULL;
|
||||
(void)arg;
|
||||
word16 peerProtosSz = 0;
|
||||
char* curr = NULL;
|
||||
char* ptr = NULL;
|
||||
|
|
@ -6129,6 +6137,7 @@ int NativeSessionTicketCb(WOLFSSL* ssl, const unsigned char* ticket,
|
|||
jclass sslClass; /* WolfSSLSession class */
|
||||
jmethodID sessTicketCbMethodId; /* internalTls13SecretCallback ID */
|
||||
jbyteArray ticketArr = NULL;
|
||||
(void)ctx;
|
||||
|
||||
if (g_vm == NULL || ssl == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
|
|
@ -6327,6 +6336,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_disableExtendedMasterSecr
|
|||
#if defined(HAVE_EXTENDED_MASTER) && !defined(NO_WOLFSSL_CLIENT)
|
||||
int ret = 0;
|
||||
WOLFSSL* ssl = (WOLFSSL*)(uintptr_t)sslPtr;
|
||||
(void)jenv;
|
||||
(void)jcl;
|
||||
|
||||
/* Checks ssl for null internally */
|
||||
|
|
|
|||
Loading…
Reference in New Issue