Skip to content

Commit

Permalink
Merge pull request #99 from akakou/hotfix/ta-bugs
Browse files Browse the repository at this point in the history
Hotfix/ta bugs
  • Loading branch information
akakou authored Sep 9, 2024
2 parents a0f1375 + 6df3d36 commit e1690f3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
1 change: 1 addition & 0 deletions ta/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func DefaultConfig() (*TAConfig, error) {
domain := os.Getenv("RA_WEBS_TA_DOMAIN")
email := os.Getenv("RA_WEBS_SERVICE_EMAIL")
verifierBase := os.Getenv("RA_WEBS_VERIFIER_BASE")

if token == "" {
return nil, fmt.Errorf("%v", ERROR_TOKEN_NOT_SET)
}
Expand Down
10 changes: 2 additions & 8 deletions ta/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ const (
ERROR_REQUEST_FAILED = "request failed"
ERROR_READ_BODY = "read body failed"
ERROR_STATUS_NOT_OK = "status not ok"
ERROR_Verifier_BASE_PARSE = "verifier base parse failed"
ERROR_VERIFIER_BASE_PARSE = "verifier base parse failed"
ERROR_REPOSITORY_NOT_SET = "failed to read RA_WEBS_TA_REPOSITORY"
ERROR_TOKEN_NOT_SET = "failed to read RA_WEBS_SERVICE_TOKEN"
ERROR_DOMAIN_NOT_SET = "failed to read RA_WEBS_TA_DOMAIN"
ERROR_EMAIL_NOT_SET = "failed to read RA_WEBS_SERVICE_EMAIL"
ERROR_Verifier_BASE_NOT_SET = "failed to read RA_WEBS_VERIFIER_BASE"
ERROR_VERIFIER_BASE_NOT_SET = "failed to read RA_WEBS_VERIFIER_BASE"
)

// token := os.Getenv("RA_WEBS_SERVICE_TOKEN")
// repository := os.Getenv("RA_WEBS_TA_REPOSITORY")
// domain := os.Getenv("RA_WEBS_TA_DOMAIN")
// email := os.Getenv("RA_WEBS_TA_EMAIL")
// verifierBase := os.Getenv("RA_WEBS_VERIFIER_BASE")
2 changes: 1 addition & 1 deletion ta/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (ta *TA) post(path string, reqBody any) (string, error) {

u, err := url.Parse(ta.config.Verifier)
if err != nil {
return "", fmt.Errorf("%v: %v", ERROR_Verifier_BASE_PARSE, err)
return "", fmt.Errorf("%v: %v", ERROR_VERIFIER_BASE_PARSE, err)
}

u.Path = path
Expand Down
5 changes: 2 additions & 3 deletions ta/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

const CERT_DIER_CACHE = "./tmp/ra-webs.cache"

func parsePemCertiifcate(raw []byte, privateKey *rsa.PrivateKey) (*tls.Certificate, error) {
func parsePemCertificate(raw []byte, privateKey *rsa.PrivateKey) (*tls.Certificate, error) {
certs := make([][]byte, 0)

for block, rest := pem.Decode(raw); block != nil; block, rest = pem.Decode(rest) {
Expand All @@ -35,7 +35,7 @@ func (ap *TA) TLSConfig() (*tls.Config, error) {

resouce := IssueCertificate(ap.privateKey, ap.config.Domain, ap.config.Email)

cert, err := parsePemCertiifcate(resouce.Certificate, ap.privateKey)
cert, err := parsePemCertificate(resouce.Certificate, ap.privateKey)

if err != nil {
return nil, err
Expand All @@ -47,4 +47,3 @@ func (ap *TA) TLSConfig() (*tls.Config, error) {
},
}, nil
}

0 comments on commit e1690f3

Please sign in to comment.