Есть ли способ связать код netty tcnative java с его собственной библиотекой c? - PullRequest
1 голос
/ 27 января 2020

Я попытался следовать инструкциям, найденным на wiki netty tcnative: https://netty.io/wiki/forked-tomcat-native.html, чтобы настроить соответствие fips для нашего сервера netty. Однако я застрял со следующей ошибкой:

Error in custom provider, java.lang.UnsatisfiedLinkError: io.netty.internal.tcnative.NativeStaticallyReferencedJniMethods.sslOpCipherServerPreference()I

При попытке запустить команду

SSL.fipsModeSet(1);

Любая помощь по этому вопросу будет принята. Спасибо

Полный код:

Maven:

<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">



<modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.test</groupId>
    <artifactId>testServer</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <artifactId>server</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>server</name>



  <properties>
    <jar.main.class>com.test.TestServer</jar.main.class>
    <os.detection.classifierWithLikes>fedora</os.detection.classifierWithLikes>
    <netty.version>4.1.42.Final</netty.version>
  </properties>



<dependencies>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-tcnative</artifactId>
      <version>2.0.21.Final</version>
      <classifier>${os.detected.classifier}</classifier>
      <groupId>io.netty</groupId>
      <artifactId>netty-common</artifactId>
      <version>${netty.version}</version>
    </dependency>

    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-handler</artifactId>
      <version>${netty.version}</version>
    </dependency>

    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec-http</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec-http2</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-epoll</artifactId>
      <version>${netty.version}</version>
      <classifier>linux-x86_64</classifier>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-kqueue</artifactId>
      <version>${netty.version}</version>
      <classifier>osx-x86_64</classifier>
    </dependency>

  </dependencies>



 <build>
    <extensions>
      <!-- Use os-maven-plugin to initialize the "os.detected" properties -->
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.6.2</version>
      </extension>
    </extensions>
    <plugins>
      <!-- Use Ant to configure the appropriate "tcnative.classifier" property -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>initialize</phase>
            <configuration>
              <exportAntProperties>true</exportAntProperties>
              <target>
                <condition property="tcnative.classifier"
                           value="${os.detected.classifier}-fedora"
                           else="${os.detected.classifier}">
                  <isset property="os.detected.release.fedora"/>
                </condition>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <!-- Build an executable JAR -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <classpathPrefix>lib/</classpathPrefix>
              <mainClass>com.test.TestServer</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>


      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>1.6</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Java:

import io.netty.internal.tcnative.SSL;

public class TestServer {
    public static void main(String[] args) throws Exception{
        System.out.println("Starting Test Server");

        SSL.fipsModeSet(1);

    }
}
...