Compiling OpenSSL for Android with Bazel

I am creating my own library for my android application with bazel.

I would like to use some OpenSSL functions as follows:

#include <jni.h>
#include <openssl/aes.h>
...
AES_encrypt(in, out, key);

How to add openssl library to bazel assembly?

Auxiliary question : which archive should I use?

openssl-1.1.0c.tar.gz
openssl-1.0.2j.tar.gz
openssl-1.0.1u.tar.gz
openssl-fips-2.0.13.tar.gz
openssl-fips-ecp-2.0.13.tar.gz

What i tried

I downloaded the archive openssl-1.0.2j. and added an entry cc_libraryto my file BUILD.

cc_library(
    name = "openssl",
    srcs = glob([
         "openssl-1.0.2j/crypto/**/*.h",
         "openssl-1.0.2j/crypto/**/*.c"
         ]),
    includes = [
        "openssl-1.0.2j",
        "openssl-1.0.2j/crypto/",
        ],
    visibility = ["//visibility:public"],
)

I have this error:

openssl-1.0.2j/crypto/dh/p512.c:60:24: fatal error: openssl/bn.h: No such file or directory
 #include <openssl/bn.h>

But I don’t understand why this code is trying to include the file from opensslwhile it is inopenssl-1.0.2j/crypto/

WITH openssl-1.1.0c

openssl-1.1.0c/include/openssl/e_os2.h:13:34: fatal error: openssl/opensslconf.h: No such file or directory
 # include <openssl/opensslconf.h>

Even if I run the command Configure, the file is not created opensslconf.h.

+4
source share
1

@Ulf Adams, OpenSSL bazel. BoringSSL.

BoringSSL fork OpenSSL bazel, :

git_repository(
    name = "boringssl",
    commit = "_some commit_",
    remote = "https://boringssl.googlesource.com/boringssl",
)
0

Source: https://habr.com/ru/post/1664189/


All Articles