Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frameworks/ring-http-exchange/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ RUN lein deps
COPY src ./src
RUN lein with-profile uberjar uberjar

FROM eclipse-temurin:26-jre
FROM eclipse-temurin:27-jre
RUN mkdir -p /data/static
WORKDIR /app
COPY --from=builder /app/target/ring-0.1.0-standalone.jar /app/app.jar

EXPOSE 8080 8081

ENTRYPOINT ["java", "-jar", "app.jar"]
ENTRYPOINT ["java", "-jar", "app.jar"]
10 changes: 8 additions & 2 deletions frameworks/ring-http-exchange/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
"repo": "https://github.com/ruroru/ring-http-exchange",
"enabled": true,
"tests": [
"baseline", "async", "latency-1m", "latency-10k", "latency-500k-8cpu",
"baseline",
"async",
"latency-1m",
"latency-10k",
"latency-500k-8cpu",
"limited-conn",
"json-comp",
"8gbit",
"json-tls",
"async-db",
"static-tls",
"fortunes"
]
],
"maintainers": ["ruroru"]

}
23 changes: 21 additions & 2 deletions frameworks/ring-http-exchange/src/ring/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
(io.vertx.sqlclient PoolOptions)
(java.io ByteArrayOutputStream FileInputStream InputStream OutputStream)
(java.net URI)
(java.security KeyStore PEMDecoder PrivateKey)
(java.security KeyFactory KeyStore PrivateKey)
(java.security.cert Certificate CertificateFactory)
(java.security.spec PKCS8EncodedKeySpec)
(java.util Base64)
(java.util.concurrent Executors)
(java.util.zip GZIPOutputStream))
(:gen-class))
Expand Down Expand Up @@ -200,11 +202,28 @@
:tags (json/read-value (str (:tags row)))
:rating {:score (:rating_score row) :count (:rating_count row)}})

(defn- pem->der ^bytes [^String pem]
(let [body (-> pem
(str/replace #"-----BEGIN [^-]+-----" "")
(str/replace #"-----END [^-]+-----" "")
(str/replace #"\s" ""))]
(.decode (Base64/getDecoder) body)))

(defn- der->private-key ^PrivateKey [^bytes der]
(let [spec (PKCS8EncodedKeySpec. der)]
(loop [algos ["RSA" "EC" "DSA" "EdDSA"]]
(if-let [algo (first algos)]
(or (try
(.generatePrivate (KeyFactory/getInstance ^String algo) spec)
(catch Exception _ nil))
(recur (rest algos)))
(throw (ex-info "Unsupported private key algorithm" {}))))))

(defn- pem->keystore [^String cert-path ^String key-path]
(let [certs (with-open [in (FileInputStream. cert-path)]
(.generateCertificates (CertificateFactory/getInstance "X.509") in))
cert-array (into-array Certificate certs)
private-key ^PrivateKey (.decode (PEMDecoder/of) ^String (slurp key-path) PrivateKey)
private-key (der->private-key (pem->der (slurp key-path)))
password (char-array 0)]
(doto (KeyStore/getInstance "PKCS12")
(.load nil password)
Expand Down
Loading