Skip to content

Commit

Permalink
Added parameters to keygen script
Browse files Browse the repository at this point in the history
  • Loading branch information
ivard authored and sietseringers committed Nov 11, 2021
1 parent cd524d7 commit 9b7ce63
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 27 deletions.
12 changes: 0 additions & 12 deletions README.markdown

This file was deleted.

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# Email server

Add an email address for use in your [IRMA app](https://github.com/privacybydesign/irma_mobile).


## Setting up the server

1. Generate JWT keys for the issuer
```bash
./utils/keygen.sh ./src/main/resources/sk ./src/main/resources/pk
```
2. Copy the file `src/main/resources/config.sample.json` to
`build/resources/main/config.json` and modify it.
3. Run `gradle appRun` in the root directory of this project.
4. Navigate to `http://localhost:8080/irma_email_issuer/api/hello`
44 changes: 29 additions & 15 deletions utils/keygen.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
#!/bin/bash

dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
# Check if openssl exists
if ! type openssl >/dev/null 2>&1; then
>&2 echo "openssl not found, exiting"
exit 1
fi

SK=$dir/../build/resources/main/sk
PK=$dir/../build/resources/main/pk
if [[ $# -eq 0 ]]; then
SK=sk
PK=pk
fi
if [[ $# -eq 1 ]]; then
>&2 echo "Either supply 0 or 2 arguments"
exit 1
fi
if [[ $# -eq 2 ]]; then
SK=$1
PK=$2
fi

if [ ! -e "$SK" ]; then
# Generate a private key in PEM format
openssl genrsa -out ${SK}.pem 2048
# Convert it to DER for Java
openssl pkcs8 -topk8 -inform PEM -outform DER -in ${SK}.pem -out ${SK}.der -nocrypt
# Calculate corresponding public key, saved in PEM format
openssl rsa -in ${SK}.pem -pubout -outform PEM -out ${PK}.pem
# Calculate corresponding public key, saved in DER format
openssl rsa -in ${SK}.pem -pubout -outform DER -out ${PK}.der
# Remove leftover files
if [ -e ${SK}.der ] || [ -e ${PK}.der ]; then
echo "Keys already exist, not generating new ones"
exit
fi
rm -f ${SK}.pem
rm -f ${PK}.pem

# Generate a private key in PEM format
openssl genrsa -out ${SK}.pem 2048
# Convert it to DER for Java
openssl pkcs8 -topk8 -inform PEM -outform DER -in ${SK}.pem -out ${SK}.der -nocrypt
# Calculate corresponding public key, saved in PEM format
openssl rsa -in ${SK}.pem -pubout -outform PEM -out ${PK}.pem
# Calculate corresponding public key, saved in DER format
openssl rsa -in ${SK}.pem -pubout -outform DER -out ${PK}.der

0 comments on commit 9b7ce63

Please sign in to comment.