Commit fdb77118 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Add GET /publickey handler to server

parent 83f221b9
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
package irmaserver package irmaserver
import ( import (
"crypto/x509"
"encoding/pem"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
...@@ -122,6 +124,8 @@ func Handler() http.Handler { ...@@ -122,6 +124,8 @@ func Handler() http.Handler {
router.Get("/session/{token}/result-jwt", handleJwtResult) router.Get("/session/{token}/result-jwt", handleJwtResult)
router.Get("/session/{token}/getproof", handleJwtProofs) // irma_api_server-compatible JWT router.Get("/session/{token}/getproof", handleJwtProofs) // irma_api_server-compatible JWT
router.Get("/publickey", handlePublicKey)
return router return router
} }
...@@ -319,3 +323,21 @@ func handleJwtProofs(w http.ResponseWriter, r *http.Request) { ...@@ -319,3 +323,21 @@ func handleJwtProofs(w http.ResponseWriter, r *http.Request) {
} }
server.WriteString(w, resultJwt) server.WriteString(w, resultJwt)
} }
func handlePublicKey(w http.ResponseWriter, r *http.Request) {
if conf.jwtPrivateKey == nil {
server.WriteError(w, server.ErrorUnsupported, "")
return
}
bts, err := x509.MarshalPKIXPublicKey(&conf.jwtPrivateKey.PublicKey)
if err != nil {
server.WriteError(w, server.ErrorUnknown, err.Error())
return
}
pubBytes := pem.EncodeToMemory(&pem.Block{
Type: "PUBLIC KEY",
Bytes: bts,
})
_, _ = w.Write(pubBytes)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment