mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Basic WildFly OpenSSL integration (using JNI)
This commit is contained in:
@@ -121,6 +121,7 @@
|
||||
<configuration>
|
||||
<reportErrorsAtRuntime>true</reportErrorsAtRuntime>
|
||||
<graalvmHome>${graalvmHome}</graalvmHome>
|
||||
<enableJni>true</enableJni>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
@@ -187,6 +187,7 @@
|
||||
<enableCodeSizeReporting>true</enableCodeSizeReporting>
|
||||
-->
|
||||
<graalvmHome>${graalvmHome}</graalvmHome>
|
||||
<enableJni>true</enableJni>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
@@ -60,6 +60,9 @@ public class NativeImageMojo extends AbstractMojo {
|
||||
@Parameter(defaultValue = "false")
|
||||
private boolean enableServer;
|
||||
|
||||
@Parameter(defaultValue = "false")
|
||||
private boolean enableJni;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
|
||||
@@ -114,6 +117,9 @@ public class NativeImageMojo extends AbstractMojo {
|
||||
if (enableCodeSizeReporting) {
|
||||
command.add("-H:+PrintCodeSizeReport");
|
||||
}
|
||||
if (enableJni) {
|
||||
command.add("-H:+JNI");
|
||||
}
|
||||
if(!enableServer) {
|
||||
command.add("--no-server");
|
||||
}
|
||||
|
||||
13
pom.xml
13
pom.xml
@@ -57,7 +57,7 @@
|
||||
<javax.persistence-api.version>2.2</javax.persistence-api.version>
|
||||
<rxjava.version>2.1.12</rxjava.version>
|
||||
<microprofile-rest-client-api.version>1.0</microprofile-rest-client-api.version>
|
||||
|
||||
<wildfly.openssl.version>1.0.6.Final</wildfly.openssl.version>
|
||||
|
||||
<graalvmHome>${env.GRAALVM_HOME}</graalvmHome>
|
||||
</properties>
|
||||
@@ -597,6 +597,17 @@
|
||||
<version>${xnio.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wildfly.openssl</groupId>
|
||||
<artifactId>wildfly-openssl-java</artifactId>
|
||||
<version>${wildfly.openssl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wildfly.openssl</groupId>
|
||||
<artifactId>wildfly-openssl-linux-x86_64</artifactId>
|
||||
<version>${wildfly.openssl.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
<groupId>org.jboss.xnio</groupId>
|
||||
<artifactId>xnio-nio</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wildfly.openssl</groupId>
|
||||
<artifactId>wildfly-openssl-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wildfly.openssl</groupId>
|
||||
<artifactId>wildfly-openssl-linux-x86_64</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.shamrock</groupId>
|
||||
|
||||
@@ -5,12 +5,13 @@ import javax.net.ssl.SSLEngine;
|
||||
import com.oracle.svm.core.annotate.Substitute;
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
import io.undertow.protocols.alpn.ALPNProvider;
|
||||
import io.undertow.protocols.alpn.OpenSSLAlpnProvider;
|
||||
|
||||
@TargetClass(className = "io.undertow.protocols.alpn.ALPNManager")
|
||||
public final class ALPNManagerSubstitution {
|
||||
|
||||
@Substitute
|
||||
public ALPNProvider getProvider(SSLEngine engine) {
|
||||
return null;
|
||||
return new OpenSSLAlpnProvider();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* JBoss, Home of Professional Open Source.
|
||||
* Copyright 2018 Red Hat, Inc., and individual contributors
|
||||
* as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jboss.shamrock.undertow.runtime.graal;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.Provider;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLContextSpi;
|
||||
import javax.net.ssl.SSLException;
|
||||
|
||||
import com.oracle.svm.core.annotate.Alias;
|
||||
import com.oracle.svm.core.annotate.Substitute;
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
import org.wildfly.openssl.OpenSSLContextSPI;
|
||||
import org.wildfly.openssl.OpenSSLProvider;
|
||||
|
||||
/**
|
||||
*/
|
||||
@TargetClass(SSLContext.class)
|
||||
public final class SSLContextSubstitution {
|
||||
|
||||
@Alias
|
||||
SSLContextSubstitution(SSLContextSpi var1, Provider var2, String var3) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Substitute
|
||||
public static SSLContext getInstance(String protocol) throws NoSuchAlgorithmException {
|
||||
return (SSLContext) (Object) new SSLContextSubstitution(Utils.getSpi(protocol), OpenSSLProvider.INSTANCE, protocol);
|
||||
}
|
||||
|
||||
@Substitute
|
||||
public static SSLContext getInstance(String protocol, String provider) throws NoSuchAlgorithmException, NoSuchProviderException {
|
||||
if (provider.equals("OpenSSL")) {
|
||||
return getInstance(protocol);
|
||||
} else {
|
||||
throw new NoSuchProviderException(provider);
|
||||
}
|
||||
}
|
||||
|
||||
@Substitute
|
||||
public static SSLContext getInstance(String protocol, Provider provider) throws NoSuchAlgorithmException {
|
||||
if (provider instanceof OpenSSLProvider) {
|
||||
return (SSLContext) (Object) new SSLContextSubstitution(Utils.getSpi(protocol), provider, protocol);
|
||||
} else {
|
||||
throw new NoSuchAlgorithmException(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
static final class Utils {
|
||||
static SSLContextSpi getSpi(String protocol) throws NoSuchAlgorithmException {
|
||||
Objects.requireNonNull(protocol, "null protocol name");
|
||||
try {
|
||||
if ("TLS".equals(protocol) || "Default".equals(protocol)) {
|
||||
return new OpenSSLContextSPI.OpenSSLTLSContextSpi();
|
||||
} else if ("TLSv1.0".equals(protocol)) {
|
||||
return new OpenSSLContextSPI.OpenSSLTLS_1_0_ContextSpi();
|
||||
} else if ("TLSv1.1".equals(protocol)) {
|
||||
return new OpenSSLContextSPI.OpenSSLTLS_1_1_ContextSpi();
|
||||
} else if ("TLSv1.2".equals(protocol)) {
|
||||
return new OpenSSLContextSPI.OpenSSLTLS_1_1_ContextSpi();
|
||||
} else {
|
||||
throw new NoSuchAlgorithmException(protocol);
|
||||
}
|
||||
} catch (SSLException e) {
|
||||
throw new NoSuchAlgorithmException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* JBoss, Home of Professional Open Source.
|
||||
* Copyright 2018 Red Hat, Inc., and individual contributors
|
||||
* as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jboss.shamrock.undertow.runtime.graal;
|
||||
|
||||
import com.oracle.svm.core.annotate.Substitute;
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
import org.wildfly.openssl.SSL;
|
||||
|
||||
/**
|
||||
*/
|
||||
@TargetClass(SSL.class)
|
||||
public final class SSLSubstitution {
|
||||
|
||||
|
||||
@Substitute
|
||||
static void init() {
|
||||
System.loadLibrary("wfssl");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user