Since it was necessary to distribute the file via https during development, check it and make a note of the implementation.
--Java / Clojure development environment is installed
--This time, I used [ring / ring-core" 1.6.2 "]
By executing the following, you can generate a keystore that contains the public key and private key information required for https.
[Detailed steps](https://www.eclipse.org/jetty/documentation/9.4.x/configuring-ssl.html#generating-key-pairs-and-certificat es)
keytool -keystore keystore -alias jetty -genkey -keyalg RSA
Specify to use file middleware that is included in ring as standard. Files under the specified directory can be distributed.
This time, [ring-jetty-adapter](https://github.com/ring-clojure/ring/blob/master/ring-jetty-adapter/src/ring/adapter/jetty. Use clj).
(require '[ring.adapter.jetty :as j]
'[ring.middleware.file :as rf])
(def jetty
(j/run-jetty
(rf/wrap-file identity ;;A handler that does nothing because it only delivers files
"." ;;I want to distribute under the project root directory
)
{:host "localhost"
:http? false ;;Because http is unnecessary
:ssl? true ;;Enable https
:ssl-port 9443 ;;Arbitrary value
:keystore "keystore" ;;Path to the first keystore created
:key-password "password";;Value used to create the keystore
:join? false ;;After booting, control returns to the REPL
}))
I used to use the https server module that came with Python, but I was happy because it could be completed easily with Clojure / Java alone.
Recommended Posts