Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
fdb77118
Commit
fdb77118
authored
Jan 08, 2019
by
Sietse Ringers
Browse files
Add GET /publickey handler to server
parent
83f221b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/irmaserver/server.go
View file @
fdb77118
...
...
@@ -2,6 +2,8 @@
package
irmaserver
import
(
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"net/http"
...
...
@@ -122,6 +124,8 @@ func Handler() http.Handler {
router
.
Get
(
"/session/{token}/result-jwt"
,
handleJwtResult
)
router
.
Get
(
"/session/{token}/getproof"
,
handleJwtProofs
)
// irma_api_server-compatible JWT
router
.
Get
(
"/publickey"
,
handlePublicKey
)
return
router
}
...
...
@@ -319,3 +323,21 @@ func handleJwtProofs(w http.ResponseWriter, r *http.Request) {
}
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
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment