From 726591384caecf89685a6b54eaebdffddc85a5a2 Mon Sep 17 00:00:00 2001
From: Linfeng Qian <thewawar@gmail.com>
Date: Fri, 12 Aug 2022 19:23:50 +0800
Subject: [PATCH] Use openssl

---
 Cargo.lock               | 11 +++++++++++
 Cargo.toml               |  2 ++
 docker/Dockerfile.x86_64 |  7 ++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/Cargo.lock b/Cargo.lock
index b550871..2ece490 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -559,6 +559,15 @@ version = "0.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
 
+[[package]]
+name = "openssl-src"
+version = "111.22.0+1.1.1q"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f31f0d509d1c1ae9cada2f9539ff8f37933831fd5098879e482aa687d659853"
+dependencies = [
+ "cc",
+]
+
 [[package]]
 name = "openssl-sys"
 version = "0.9.75"
@@ -568,6 +577,7 @@ dependencies = [
  "autocfg 1.1.0",
  "cc",
  "libc",
+ "openssl-src",
  "pkg-config",
  "vcpkg",
 ]
@@ -911,6 +921,7 @@ dependencies = [
  "mime_guess 2.0.4",
  "multipart",
  "open",
+ "openssl",
  "path-dedot",
  "percent-encoding 2.1.0",
  "pretty-bytes",
diff --git a/Cargo.toml b/Cargo.toml
index d6dc911..368595f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,6 +21,7 @@ pretty-bytes = "0.2.2"
 rand = "0.8.3"
 url = "2.1.0"
 hyper-native-tls = { version = "0.3.0", optional = true }
+openssl = { version = "0.10", features = ["vendored"], optional = true }
 mime_guess = "2.0"
 open = "1"
 # Iron crates
@@ -33,4 +34,5 @@ path-dedot = "1"
 
 [features]
 default = ["tls"]
+only-openssl = ["tls", "openssl"]
 tls = ["hyper-native-tls"]
diff --git a/docker/Dockerfile.x86_64 b/docker/Dockerfile.x86_64
index 6e5c1cc..bac9380 100644
--- a/docker/Dockerfile.x86_64
+++ b/docker/Dockerfile.x86_64
@@ -7,7 +7,12 @@ FROM rust:1.61-alpine3.15 as builder
 ARG BRANCH
 RUN apk add --no-cache --virtual .build-deps git make musl-dev openssl-dev perl pkgconfig \
     && git clone -b $BRANCH https://github.com/TheWaWaR/simple-http-server.git /simple-http-server \
-    && RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-musl --manifest-path=/simple-http-server/Cargo.toml
+    && RUSTFLAGS='-C link-arg=-s' cargo build \
+    --features only-openssl \
+    --no-default-features \
+    --release \
+    --target x86_64-unknown-linux-musl \
+    --manifest-path=/simple-http-server/Cargo.toml
 
 FROM gcr.io/distroless/static:nonroot
 LABEL maintainer="thewawar <thewawar@gmail.com>" \
-- 
GitLab