Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.0.1 🎉 #121

Merged
merged 706 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
706 commits
Select commit Hold shift + click to select a range
8c18ef7
feat: sslmate
akakou May 14, 2024
817e24a
fix: sleep time
akakou May 14, 2024
9171d78
fix: make sslmate default
akakou May 14, 2024
5cb2bfd
refactor: remove unused file
akakou May 14, 2024
fd95c6b
chore: go mod tidy
akakou May 14, 2024
c4ad642
refactor: place of update function
akakou May 14, 2024
4448c60
feat: add setup to example
akakou May 14, 2024
142042c
fix: place of last file reading
akakou May 14, 2024
38ed715
fix: last read
akakou May 14, 2024
0884bb2
Merge pull request #64 from akakou/feature/multiple-ct
akakou May 14, 2024
64cf0dc
chore: go mod tidy
akakou May 14, 2024
b909291
feat: update issue service cmd
May 14, 2024
6deab9f
Merge pull request #65 from akakou/feature/issue_serice.sh
akakou May 14, 2024
9cb349f
fix: sync db
akakou May 14, 2024
0871cc2
fix: remove domain deplications
akakou May 14, 2024
db954b2
fix: make sleep time dynamic
akakou May 14, 2024
38debd8
Merge pull request #66 from akakou/hotfix/sslmate-ct-not-work
akakou May 14, 2024
72e8f50
fix: audit ignoring certificate miss
akakou May 14, 2024
b0f3f63
fix: zero division error
akakou May 14, 2024
e2b89c4
Merge pull request #67 from akakou/hotfix/auditing-errors
akakou May 14, 2024
9953467
chore: ignore db
akakou May 14, 2024
937af34
Merge pull request #68 from akakou/hotfix/auditing-errors
akakou May 14, 2024
5bde9c3
chore: ignore last.txt
akakou May 14, 2024
56c7b06
fix: bug writing file named body
akakou May 14, 2024
e7297a5
fix: add new lines
akakou May 14, 2024
d98e69a
feat: show error when revoking
akakou May 14, 2024
5a081af
fix: sleep caluclation method
akakou May 14, 2024
d6c57ad
test: sslmate
akakou May 14, 2024
694f4f8
Merge pull request #69 from akakou/test/sslmate
akakou May 14, 2024
6439da6
fix: remove unneeded print
akakou May 14, 2024
53f5464
Merge pull request #70 from akakou/hotfix/remove-unneeded-print
akakou May 14, 2024
30354a5
fix: remove syncronization
akakou May 14, 2024
52d2392
Merge pull request #71 from akakou/hotfix/pararelize-ct
akakou May 14, 2024
9917e2d
fix: make monitor struct to tamper the self change bug
akakou May 14, 2024
2133753
Merge pull request #72 from akakou/feature/self-change
akakou May 14, 2024
d7c0a83
chore: go mod tidy
akakou May 14, 2024
9637eb2
fix: unique id bug
akakou May 14, 2024
1e391ed
fix: ensure folder name unique ness
akakou May 14, 2024
ff5430b
feat: sync latest id at provisioning phase & remove last file
akakou May 14, 2024
20f184c
Merge pull request #73 from akakou/feature/auto-loop-id
akakou May 14, 2024
ba1dcfc
feat: reflect subscrpption
akakou May 14, 2024
623a798
fix: auto test case
akakou May 14, 2024
2de7bb9
Merge pull request #75 from akakou/hotfix/auto-test-case
akakou May 14, 2024
a67f585
Merge pull request #74 from akakou/feature/reflect-subscrptpion
akakou May 14, 2024
c079846
fix: remove second golang package
akakou May 15, 2024
073a4f8
fix: set build vcs = false
akakou May 15, 2024
9db34b9
Merge pull request #76 from akakou/hotfix/build-version
akakou May 15, 2024
5d5723a
fix: add trimpath for reproducible build
akakou May 15, 2024
ebae8d0
Merge pull request #77 from akakou/hotfix/reproducible
akakou May 15, 2024
1191bc2
Merge pull request #78 from akakou/hotfix/uniqueid-wrong
akakou May 15, 2024
63c0b9d
fix: compose setting
akakou May 15, 2024
7d0a117
Merge pull request #79 from akakou/hotfix/compose-settings
akakou May 15, 2024
770fd82
chore: ignore keys
akakou Jun 11, 2024
3a02f42
feat: running API
akakou Jun 11, 2024
f2284d3
refactor: use private function
akakou Jun 11, 2024
0569a94
feat: remove unused ct monitor
akakou Jun 17, 2024
71baddc
feat: direct ct auditor
akakou Jun 17, 2024
8da9e72
fix: remove subscribe
akakou Jun 17, 2024
0dc9c26
refactor: redesign the auditor' apis
akakou Jun 17, 2024
ca3f6d2
refactor: remove audit one and all
akakou Jun 17, 2024
4c8152c
chore: go mod
akakou Jun 17, 2024
c40ba81
fix: spell of localhost
akakou Jun 17, 2024
555c9d7
feat: fix admin token
akakou Jun 17, 2024
3e2b4e6
Merge branch 'develop' into feature/ct-direct
akakou Jun 17, 2024
83050e8
test: auto deploy
akakou Jun 18, 2024
20cbc1f
fix: run auditing
akakou Jun 18, 2024
c154e24
fix: check rsa public key
akakou Jun 18, 2024
a3ef99c
fix: ct params
akakou Jun 18, 2024
8424c9b
chore: go mod tidy
akakou Jun 18, 2024
c2ae674
Merge pull request #80 from akakou/feature/ct-direct
akakou Jun 18, 2024
b4fcf97
fix: error message when public key is not rsa
akakou Jun 18, 2024
142351c
Merge pull request #81 from akakou/hotfix/non-rsa-error
akakou Jun 18, 2024
4292678
fix: remove domain owner
akakou Jun 18, 2024
cbdbe2f
Merge pull request #82 from akakou/feature/remove-domain-owner
akakou Jun 18, 2024
4581bc6
feat: subscription db model
akakou Jun 18, 2024
cd33403
feat: divide subscription column into multiple column
akakou Jun 20, 2024
5d5321f
feat: notifying compornents
akakou Jun 20, 2024
098d173
feat: subscribtion api
akakou Jun 20, 2024
a3882e8
feat: apply notifying feature into ttp
akakou Jun 20, 2024
f03b6f0
fix: the bug of initialization of vapid keys
akakou Jun 25, 2024
0ccfec9
feat: api endpoint for subscription key
akakou Jun 25, 2024
ec51d2a
chore: install web push library
akakou Jun 25, 2024
0147279
feat: set up notification script
akakou Jun 25, 2024
4c65e5e
feat: service worker for notification
akakou Jun 25, 2024
a10f2d3
feat: apply script for notifcation
akakou Jun 25, 2024
6157d72
feat: load script and set header for sw
akakou Jun 25, 2024
fbe427d
fix: add unique
akakou Jun 25, 2024
a2bdacc
feat: send domain with notification
akakou Jun 25, 2024
319d2a0
test: fix bug by adding empty notify for test
akakou Jun 25, 2024
f24dd3b
test: fix the unique id
akakou Jun 25, 2024
c671b3b
feat: notifcation api for admin
akakou Jun 25, 2024
c440047
fix: rename to add "api"
akakou Jun 25, 2024
33b80a1
feat: endpoint for admin to notify
akakou Jun 25, 2024
b327663
chore: test script to notify
akakou Jun 25, 2024
9b707af
fix: query servers from domain when notify
akakou Jun 25, 2024
c289f5e
feat: notify when update
akakou Jun 25, 2024
56af7a4
fix: revoke functions obtain ttp
akakou Jun 25, 2024
6f0367c
feat: notify violation
akakou Jun 25, 2024
fdc675f
Merge pull request #83 from akakou/feature/notify
akakou Jun 25, 2024
6a43ac5
fix: the redirection after some time
akakou Jul 27, 2024
7fe15f2
Merge pull request #84 from akakou/hotfix/redirect-waiting
akakou Jul 27, 2024
f5a806f
chore: update ctstreams
akakou Aug 6, 2024
25cae78
Merge pull request #85 from akakou/chore/update-ctstream
akakou Aug 6, 2024
d3e9bfc
chore: upgrade ct-monitor
akakou Aug 30, 2024
3c0cb19
chore: set stable ct logs
akakou Aug 30, 2024
2d330a5
Merge pull request #86 from akakou/chore/update-ctstream
akakou Aug 30, 2024
99ca16e
refactor: rename the server to ta
akakou Sep 3, 2024
cabe913
refactor: rename the server to ta
akakou Sep 3, 2024
1cf1fab
Merge pull request #87 from akakou/refactor/server2ta
akakou Sep 3, 2024
9c2c846
fix: remove code api
akakou Sep 3, 2024
5c93a18
feat: set tile and message
akakou Sep 3, 2024
5009113
Merge pull request #88 from akakou/feature/remove-code-api
akakou Sep 3, 2024
783aeb0
Merge pull request #89 from akakou/feature/notify-browser-specified-m…
akakou Sep 3, 2024
c8fe10b
chore: upgrade monitor
akakou Sep 7, 2024
3e576d2
feat: follow update of the direct auditor
akakou Sep 7, 2024
f34b906
chore: upgrade monitor
akakou Sep 7, 2024
ec75365
feat: add to suuport sslmate
akakou Sep 7, 2024
4be354c
Merge pull request #90 from akakou/feature/support-multi-monitor
akakou Sep 7, 2024
8547418
refactor: rename filename ttp => verifier
akakou Sep 7, 2024
9672db4
refactor: rename filename audit => monitor
akakou Sep 7, 2024
8188257
refactor: rename filename notify => notifier
akakou Sep 7, 2024
8f2ab2d
refactor: rename names names
akakou Sep 7, 2024
3f49245
refactor: rename filenames
akakou Sep 7, 2024
db61e20
fix: rename `notifier` => `notify` for verbe
akakou Sep 7, 2024
a158a20
Merge pull request #91 from akakou/feature/rename
akakou Sep 7, 2024
98ad9b9
fix: rename misstake ttp => verifier
akakou Sep 7, 2024
8736211
fix: rename RA_WEBS_Verifier_BASE => RA_WEBS_VERIFIER_BASE
akakou Sep 7, 2024
8672ca2
Merge pull request #92 from akakou/fix/name-mistake
akakou Sep 7, 2024
ee00e70
feat: set hostname
akakou Sep 7, 2024
4b717bc
feat: set auto tls
akakou Sep 7, 2024
24fd7a5
Revert "feat: set hostname"
akakou Sep 7, 2024
3c4d1ae
Merge pull request #93 from akakou/feature/network-settings
akakou Sep 7, 2024
7fec75c
fix: remove domain owner container
akakou Sep 7, 2024
4f0cc70
fix: remove ngrok docker container
akakou Sep 7, 2024
790925c
Merge pull request #94 from akakou/feature/network-settings
akakou Sep 7, 2024
9c87b1f
refactor: monitor logic
akakou Sep 7, 2024
429e07d
fix: typo (Monitoror => Monitor)
akakou Sep 7, 2024
80d9ff8
Merge pull request #95 from akakou/refactor/monitors
akakou Sep 7, 2024
9c695b8
chore: upgrade ctstream
akakou Sep 7, 2024
d0bb6ca
fix: test name
akakou Sep 7, 2024
fe9c75a
fix: reduce the screen output
akakou Sep 7, 2024
9a1b76f
Merge pull request #96 from akakou/refactor/monitors
akakou Sep 7, 2024
7c986af
fix: update file names
akakou Sep 7, 2024
8e1f989
fix: error name missing
akakou Sep 7, 2024
747451c
fix: reduce stdout
akakou Sep 7, 2024
1a9605c
fix: typo `Monitoror` => `Monitor`
akakou Sep 7, 2024
0fefac1
Merge pull request #97 from akakou/refactor/monitors
akakou Sep 7, 2024
36b4d1f
refactor: rename the Verifier => VERIFIER because they are constant
akakou Sep 7, 2024
6df3d36
fix: parsePemCertiifcate => parsePemCertificate
akakou Sep 7, 2024
3ac000a
chore: update packages
akakou Sep 8, 2024
c10409e
chore: update go packages
akakou Sep 8, 2024
6573bc5
fix: bugs the network access failed
akakou Sep 8, 2024
aaf5a4e
chore: update go packages
akakou Sep 8, 2024
bd870e0
fix: environment value name
akakou Sep 8, 2024
a0f1375
Merge pull request #98 from akakou/hotfix/broken
akakou Sep 8, 2024
e1690f3
Merge pull request #99 from akakou/hotfix/ta-bugs
akakou Sep 9, 2024
9ec534a
fix: merge build script
akakou Sep 9, 2024
8daca16
feat: build without docker
akakou Sep 9, 2024
2fca795
fix: remove unused dockerfile
akakou Sep 9, 2024
2bebb90
fix: the output line
akakou Sep 9, 2024
25db6a3
fix: set executable file name
akakou Sep 9, 2024
ff06516
fix: index of command argument
akakou Sep 9, 2024
0d5992b
feat: store logs as file
akakou Sep 9, 2024
85568f7
fix: BASE_PROGRAM_PATH is missing
akakou Sep 9, 2024
aa19efd
fix: executable was not flexible
akakou Sep 9, 2024
7c3f3b1
chore: argument checker
akakou Sep 9, 2024
a1551e6
fix: use bash instead of sh
akakou Sep 9, 2024
b7689d6
Merge pull request #100 from akakou/feature/direct-building
akakou Sep 9, 2024
08d8290
chore: make public tunnel with cloudflare
akakou Sep 9, 2024
b62c1ee
fix: deploy non-tls server (because of using cloudflare tunnel)
akakou Sep 9, 2024
13102d3
feat: add error handing of tls listening
akakou Sep 9, 2024
484c15d
Merge pull request #101 from akakou/hotfix/bugs
akakou Sep 9, 2024
af77318
fix: set content type
akakou Sep 9, 2024
89c31af
Merge pull request #102 from akakou/hotfix/bugs
akakou Sep 9, 2024
07a8079
chore: ignore *.sqlite3
akakou Sep 9, 2024
95611ef
fix: use once instead of first
akakou Sep 9, 2024
ffa4411
fix: file name `notifier.js` => `notify.js`
akakou Sep 9, 2024
fd6fb16
Merge pull request #103 from akakou/hotfix/some-fixs
akakou Sep 9, 2024
f82d6b9
fix: remove sqlite3
akakou Sep 9, 2024
59f155c
Merge pull request #104 from akakou/hotfix/some-fixs
akakou Sep 9, 2024
9cc5443
fix: use referer instead of example
akakou Sep 9, 2024
ebd7444
Merge pull request #105 from akakou/hotfix/some-fixs
akakou Sep 9, 2024
fe57828
feat: compute the validity on the server
akakou Sep 9, 2024
2f7984a
fix: use received valid flag
akakou Sep 9, 2024
68d8cc5
Merge pull request #106 from akakou/feature/validate-on-server
akakou Sep 9, 2024
e60c228
fix: getting title from service worker
akakou Sep 9, 2024
f594e68
fix: remove unneccesary selecting db
akakou Sep 9, 2024
a164cd7
refactor: notifier => notify
akakou Sep 9, 2024
b2e47f4
Merge pull request #107 from akakou/hotfix/notification
akakou Sep 9, 2024
2db32f4
chore: adversary example
akakou Sep 9, 2024
74cf6b8
Merge pull request #108 from akakou/chore/sample-malicious-server
akakou Sep 9, 2024
617d56a
chore: upgrade ct-monitor
akakou Sep 10, 2024
5012676
feat: function interface called provisioning
akakou Sep 10, 2024
df67e50
feat: make sslmate as default
akakou Sep 10, 2024
bca4715
feat: add ctlog index into db
akakou Sep 10, 2024
19592fc
chore: upgrade ctstream
akakou Sep 10, 2024
927939d
feat: support sslmate
akakou Sep 10, 2024
dd935bb
Revert "feat: add ctlog index into db"
akakou Sep 10, 2024
6ba2bf2
chore: upgrade ctstream
akakou Sep 11, 2024
6b52740
feat: use echo group
akakou Sep 11, 2024
6ff2b82
chore: remove unused pacakge
akakou Sep 11, 2024
9c5d3f0
feat: specialize sslmate
akakou Sep 11, 2024
5c5331c
fix: remove testPassNoTAServer
akakou Sep 11, 2024
e723b6c
chore: upgrade goutils
akakou Sep 11, 2024
09e38fd
chore: upgrade go-utils
akakou Sep 11, 2024
2da501f
chore: ignore the logfile
akakou Sep 11, 2024
63786fc
fix: load monitors
akakou Sep 11, 2024
6169fdb
fix: use group instead of set api path directly
akakou Sep 11, 2024
1620dd6
Merge pull request #109 from akakou/feature/use-only-sslmate
akakou Sep 11, 2024
c49eab4
chore: upgrade ctstream
akakou Sep 12, 2024
d7ef4cd
chore: upgrade ctstream
akakou Sep 12, 2024
a6517a4
feat: use crtsh
akakou Sep 12, 2024
644ddba
Merge pull request #110 from akakou/feature/use-crtsh
akakou Sep 12, 2024
0abd230
refactor: remove unused pathes
akakou Sep 12, 2024
a8d7954
fix: error handling
akakou Sep 12, 2024
afe4ddf
fix: error handling
akakou Sep 12, 2024
63a4ffb
Merge pull request #111 from akakou/feature/error-handling
akakou Sep 12, 2024
b7885d6
chore: set epoch time for debug
akakou Sep 12, 2024
51f4b04
Merge branch 'feature/set-epoch' into develop
akakou Sep 12, 2024
5540808
fix: failed if the other certificate exists
akakou Sep 12, 2024
998c4e5
chore: upgrade packages
akakou Sep 12, 2024
cb98359
refactor: use EXCLUDE_EXPIRED
akakou Sep 12, 2024
79627a2
Merge pull request #112 from akakou/hotfix/crtsh-monitor-bugs
akakou Sep 12, 2024
c2e887d
chore: upgrade ctstream
akakou Sep 12, 2024
ddfc3d0
chore: upgrade ctstream
akakou Sep 12, 2024
9f28c8a
fix: precheck and register monitor
akakou Sep 12, 2024
4441651
fix: securing registration flow from abrupt end
akakou Sep 12, 2024
9731064
Merge pull request #113 from akakou/hotfix/registration
akakou Sep 12, 2024
4accdfa
fix: over flow errror
akakou Sep 12, 2024
2fd4b02
fix: error type
akakou Sep 12, 2024
a06c7f5
feat: store and restore first id
akakou Sep 12, 2024
986e99e
chore: ignore log file
akakou Sep 12, 2024
3bdeb48
Merge pull request #114 from akakou/hotifix/bugs
akakou Sep 12, 2024
a6e9e3c
Merge pull request #115 from akakou/feature/store-log
akakou Sep 12, 2024
b38e999
chore: upgrade packages
akakou Sep 13, 2024
8a9b54e
fix: show log
akakou Sep 13, 2024
5f50e2b
chore: show log
akakou Sep 13, 2024
26f78d2
fix: unexpected making the ct clint
akakou Sep 13, 2024
22f29e7
Merge pull request #116 from akakou/hotfix/unexpected-making-ctclint
akakou Sep 13, 2024
d5a03f5
refactor: format
akakou Sep 13, 2024
139e40a
fix: miss of restoring first
akakou Sep 13, 2024
b2a718f
refacor: the register and builder
akakou Sep 13, 2024
d65d8f6
Merge pull request #117 from akakou/hotfix/restore-first
akakou Sep 13, 2024
433549c
Merge pull request #118 from akakou/refactor/maybe-final
akakou Sep 13, 2024
b0afa70
fix: registering code missing
akakou Sep 13, 2024
9554b25
Merge pull request #119 from akakou/hotfix/register-missing
akakou Sep 13, 2024
fd45cdb
fix: remove unused test code
akakou Sep 15, 2024
3d6e244
fix: env file
akakou Sep 15, 2024
a1a895a
refactor: shell script
akakou Sep 15, 2024
fa0426f
Merge pull request #120 from akakou/feature/release
akakou Sep 15, 2024
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
25 changes: 25 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.5'

- name: Test
run: sh .github/workflows/test.sh
5 changes: 5 additions & 0 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd test && go test .
cd ..
cd verifier/api && go test .
cd ../../
cd verifier/monitor && go test .
23 changes: 22 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
# hverifiers://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
Expand All @@ -19,3 +19,24 @@

# Go workspace file
go.work
/verifier/verifier
/verifier/serv/serv
ta/certificate.pem
ta/private.key
ta/example/example
verifier/ca_test.json

**/repo
service/cmd/cmd
opt/domain-owner/example/config.yaml
opt/domain-owner/example/example
**/*.env

**/*.db
**/*.sqlite3

**/last.txt
ta/example/private.pem
ta/example/public.pem
verifier/serv/last.log
verifier/serv/first-log.txt
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# RA-WEBs
[![Go](https://github.com/akakou/ra-webs/actions/workflows/go.yml/badge.svg)](https://github.com/akakou/ra-webs/actions/workflows/go.yml)

RA-WEBs: Remote Attestation for WEB services
46 changes: 46 additions & 0 deletions compose.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: '3'
services:
ta_example:
tty: true
build: ./docker
network_mode: host
volumes:
- ./ta:/ta
- ./core:/core
- ./test:/test
- /dev:/dev
working_dir: /ta/example
command: bash -c 'mount -o remount,exec /dev && ego-go build -buildvcs=false -trimpath=true && ego sign example && source /test/issue_service.sh && ego run example'
privileged: true
environment:
- OE_SIMULATION=0
env_file:
- test/env/ta.env
- test/env/common.env
profiles:
- ta

verifier:
build: ./docker
volumes:
- ./verifier:/verifier
- ./core:/core
- /var/run/docker.sock:/var/run/docker.sock
working_dir: /verifier/serv
command: bash -c 'go mod tidy && go run main.go'
env_file:
- test/env/verifier.env
- test/env/common.env
privileged: true
tty: true
profiles:
- verifier

tunnel:
restart: unless-stopped
image: cloudflare/cloudflared
command: tunnel --url http://verifier:8080
env_file:
- test/env/tunnel.env
profiles:
- verifier
58 changes: 58 additions & 0 deletions core/attest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package core

import (
"bytes"
"errors"
"fmt"

"github.com/edgelesssys/ego/attestation"
"github.com/edgelesssys/ego/enclave"
)

const SECURITY_VERSION = 1

var AttestByAzure = attestByAzure
var VerifyByAzure = verifyByAzure

func AttestServer(publicKey []byte, token string) (string, error) {
buf := append([]byte(token), publicKey...)
quote, err := AttestByAzure(buf)
return quote, err
}

func VerifyServer(quote string, publicKey []byte, token string) (*attestation.Report, error) {
buf := append([]byte(token), publicKey...)
report, err := VerifyByAzure(quote, []byte(buf))
return report, err
}

func attestByAzure(data []byte) (string, error) {
if DEBUG {
return "", nil
}

// publicKeyHash := hashPublicKey(publicKey)
token, err := enclave.CreateAzureAttestationToken(data, ATTEST_PROVIDER_URL)
if err != nil {
return "", fmt.Errorf("%s: %w", ERROR_CREATE_ATTESTATION, err)
}

return token, nil
}

func verifyByAzure(quote string, data []byte) (*attestation.Report, error) {
report, err := attestation.VerifyAzureAttestationToken(quote, ATTEST_PROVIDER_URL)
if err != nil {
return nil, fmt.Errorf("%s: %w", ERROR_VERIFY_ATTESTATION, err)
}

if report.SecurityVersion < SECURITY_VERSION {
return nil, errors.New(ERROR_INVALID_SECURITY_VERSION_IN_ATTESTATION)
}

if !bytes.Equal(report.Data, data) {
return nil, errors.New(ERROR_INVALID_REPORT_DATA_IN_ATTESTATION)
}

return &report, nil
}
23 changes: 23 additions & 0 deletions core/debug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package core

import "github.com/edgelesssys/ego/attestation"

func debugAttestByAzure(data []byte) (string, error) {
return "", nil
}

func debugVerifyByAzure(token string, data []byte) (*attestation.Report, error) {
return &attestation.Report{
UniqueID: []byte{1, 2, 3},
Data: []byte{4, 5, 6},
}, nil
}

const DEBUG_TOKEN = "this-is-ra-webs-debug-token-138484039348"

func EnableDebug() {
DEBUG = true

AttestByAzure = debugAttestByAzure
VerifyByAzure = debugVerifyByAzure
}
8 changes: 8 additions & 0 deletions core/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package core

const (
ERROR_INVALID_SECURITY_VERSION_IN_ATTESTATION = "invalid security version in attestation"
ERROR_INVALID_REPORT_DATA_IN_ATTESTATION = "invalid report data in attestation"
ERROR_CREATE_ATTESTATION = "failed to create attestation"
ERROR_VERIFY_ATTESTATION = "failed to verify attestation"
)
10 changes: 10 additions & 0 deletions core/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/akakou/ra_webs/core

go 1.21.4

require github.com/edgelesssys/ego v1.5.0

require (
golang.org/x/crypto v0.21.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
)
20 changes: 20 additions & 0 deletions core/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/edgelesssys/ego v1.4.1 h1:Ef2UQvGVEf0RqarDidWywhOVLik/LnZbJG0ygdVJDAA=
github.com/edgelesssys/ego v1.4.1/go.mod h1:8xFWTj9hcHyYL7s7fMmKgdYTi5zETPy6PeZip7OBTNA=
github.com/edgelesssys/ego v1.5.0 h1:euwXc69GRGlxpklIaVZtyh0v27YXzf9ow3iODE7CrPc=
github.com/edgelesssys/ego v1.5.0/go.mod h1:N58b0J+s3U4sxXeNUT5uiQV9Q9M/U2KsILC44Ku5dnw=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
13 changes: 13 additions & 0 deletions core/param.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package core

const ATTEST_PROVIDER_URL = "https://shareduks.uks.attest.azure.net"

var X509_EXTENSION_LABEL = []int{1, 3, 6, 1, 4, 1, 11129, 2, 4, 5}

var DEBUG = false

var VerifierPort = ":8000"
var ServicePort = ":8001"
var TAPort = ":443"

const API_ROOT = "/api"
16 changes: 16 additions & 0 deletions core/struct.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package core

type CodeRequest struct {
Repository string `json:"repository"`
}

type ServerRequest struct {
PublicKey []byte `json:"public_key"`
Domain string `json:"domain"`
Quote string `json:"quote"`
}

type RegisterRequest struct {
CodeRequest `json:"code"`
ServerRequest `json:"server"`
}
36 changes: 36 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:20.04

ENV GOROOT=/usr/local/go
ENV GOPATH=$HOME/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH

ENV TZ=Asia/Tokyo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update -y && apt-get install -y wget gnupg2 docker docker.io

RUN echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | tee /etc/apt/sources.list.d/intel-sgx.list
RUN wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | apt-key add -

RUN echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main" | tee /etc/apt/sources.list.d/llvm-toolchain-focal-11.list
RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -

RUN echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/20.04/prod focal main" | tee /etc/apt/sources.list.d/msprod.list
RUN wget -qO - https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

RUN wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz

RUN apt-get update -y
RUN apt-get install -qq -y snapd build-essential libssl-dev clang-11 libssl-dev gdb libsgx-enclave-common libsgx-quote-ex libprotobuf17 libsgx-dcap-ql libsgx-dcap-ql-dev az-dcap-client open-enclave software-properties-common

RUN wget https://github.com/edgelesssys/ego/releases/download/v1.5.3/ego_1.5.3_amd64_ubuntu-20.04.deb
RUN apt-get install ./ego_1.5.3_amd64_ubuntu-20.04.deb

RUN apt-get install -y ca-certificates curl




# if you do not use azure
# ego install libsgx-dcap-default-qpl
81 changes: 81 additions & 0 deletions ta/acme.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package ta

import (
"crypto"
"crypto/rsa"
"crypto/rand"
"log"

"github.com/go-acme/lego/v4/certificate"
"github.com/go-acme/lego/v4/challenge/tlsalpn01"
"github.com/go-acme/lego/v4/lego"
"github.com/go-acme/lego/v4/registration"
)

var acmeURL = lego.LEDirectoryProduction
//var acmeURL = lego.LEDirectoryStaging

type MyUser struct {
Email string
Registration *registration.Resource
key crypto.PrivateKey
}

func (u *MyUser) GetEmail() string {
return u.Email
}
func (u MyUser) GetRegistration() *registration.Resource {
return u.Registration
}
func (u *MyUser) GetPrivateKey() crypto.PrivateKey {
return u.key
}

func IssueCertificate(key crypto.PrivateKey, domain, email string) *certificate.Resource {
// Create a user. New accounts need an email and private key to start.
privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
log.Fatal(err)
}

myUser := MyUser{
Email: email,
key: privateKey,
}

config := lego.NewConfig(&myUser)

// This CA URL is configured for a local dev instance of Boulder running in Docker in a VM.
config.CADirURL = acmeURL
// config.Certificate.KeyType = certcrypto.RSA2048

// A client facilitates communication with the CA server.
client, err := lego.NewClient(config)
if err != nil {
log.Fatal(err)
}

client.Challenge.SetTLSALPN01Provider(tlsalpn01.NewProviderServer("", "443"))
if err != nil {
log.Fatal(err)
}

// New users will need to register
reg, err := client.Registration.Register(registration.RegisterOptions{TermsOfServiceAgreed: true})
if err != nil {
log.Fatal(err)
}
myUser.Registration = reg

request := certificate.ObtainRequest{
Domains: []string{domain},
PrivateKey: key,
}

certificates, err := client.Certificate.Obtain(request)
if err != nil {
log.Fatal(err)
}

return certificates
}
Loading
Loading