Skip to content

Commit

Permalink
helper and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
wistefan committed Feb 19, 2024
1 parent e3af8ad commit d61870e
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Check PR

on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
branches:
- main

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: '11'
java-package: jdk

- id: bump
uses: zwaldowski/match-label-action@v1
with:
allowed: major,minor,patch

- uses: zwaldowski/semver-release-action@v2
with:
dry_run: true
bump: ${{ steps.bump.outputs.match }}
github_token: ${{ secrets.GITHUB_TOKEN }}

comment:
runs-on: ubuntu-latest
if: always()
steps:
- uses: technote-space/workflow-conclusion-action@v2
- name: Checkout
uses: actions/checkout@v1

- name: Comment PR
if: env.WORKFLOW_CONCLUSION == 'failure'
uses: thollander/[email protected]
with:
message: "Please apply one of the following labels to the PR: 'patch', 'minor', 'major'."
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68 changes: 68 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release

on:
push:
branches:
- main

jobs:
generate-version:
runs-on: ubuntu-latest

outputs:
version: ${{ steps.out.outputs.version }}

steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: '11'
java-package: jdk

- id: pr
uses: actions-ecosystem/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- uses: zwaldowski/semver-release-action@v2
with:
dry_run: true
bump: ${{ steps.pr.outputs.labels }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Set version output
id: out
run: echo "::set-output name=version::$(echo ${VERSION})"

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

- uses: actions/setup-go@v5
with:
go-version: '>= 1.21.5'

- name: build
run: |
go build .
git-release:
needs:
- generate-version
- build

runs-on: ubuntu-latest

steps:

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ needs.generate-version.outputs.version }}
prerelease: false
title: ${{ needs.generate-version.outputs.version }}
files: |
did-helper
LICENSE
2 changes: 1 addition & 1 deletion did/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func GetDIDKeyFromECPKCS12(path, password string) (did string, err error) {
return did, err
}

ecKey, ok := privateKey.(ecdsa.PrivateKey)
ecKey, ok := privateKey.(*ecdsa.PrivateKey)
if !ok {
zap.L().Sugar().Warnf("Keystore %s does not contain a valid EC Private Key.", path)
return did, errors.New("no_ec_private_key")
Expand Down
17 changes: 17 additions & 0 deletions example/cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICrTCCAlOgAwIBAgIUdgd42VBe83+X4DA2LPxwXEHrmUAwCgYIKoZIzj0EAwIw
gasxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxp
bjEkMCIGA1UECgwbRklXQVJFIEZvdW5kYXRpb24gZS5WLiBUZXN0MRIwEAYDVQQL
DAlUZWNoIFRlYW0xFDASBgNVBAMMC0ZJV0FSRSBUZXN0MSowKAYJKoZIhvcNAQkB
FhtzdGVmYW4ud2llZGVtYW5uQGZpd2FyZS5vcmcwHhcNMjQwMjE5MDgyMjQwWhcN
MjUwMjEzMDgyMjQwWjCBqzELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEP
MA0GA1UEBwwGQmVybGluMSQwIgYDVQQKDBtGSVdBUkUgRm91bmRhdGlvbiBlLlYu
IFRlc3QxEjAQBgNVBAsMCVRlY2ggVGVhbTEUMBIGA1UEAwwLRklXQVJFIFRlc3Qx
KjAoBgkqhkiG9w0BCQEWG3N0ZWZhbi53aWVkZW1hbm5AZml3YXJlLm9yZzBZMBMG
ByqGSM49AgEGCCqGSM49AwEHA0IABEXPFhi84TWcSAbNaVudRGs80ggUw35zdGAY
BmLQoyvjvx1xweVnYm+a21NFFB/g9X28Yyy4/pe9IqG6Bou0p6OjUzBRMB0GA1Ud
DgQWBBRJKKfPFS9ZJXKRSKp7+C3peM5gcDAfBgNVHSMEGDAWgBRJKKfPFS9ZJXKR
SKp7+C3peM5gcDAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMCA0gAMEUCIQCT
FcGGCkIPX9wGy0mjELzCkiRlYi/RaXqUk41wcxNx1wIgB/AUHSGc2z1guEByQwpv
94dmlm1gGaHEuRyji0rhw28=
-----END CERTIFICATE-----
Binary file added example/cert.pfx
Binary file not shown.
5 changes: 5 additions & 0 deletions example/private-key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIF3NwGK4z4LR533/7mXaQNcWCfglL/AbO5wkb3ltQ5rdoAoGCCqGSM49
AwEHoUQDQgAERc8WGLzhNZxIBs1pW51EazzSCBTDfnN0YBgGYtCjK+O/HXHB5Wdi
b5rbU0UUH+D1fbxjLLj+l70ioboGi7Snow==
-----END EC PRIVATE KEY-----
4 changes: 4 additions & 0 deletions example/public-key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAERc8WGLzhNZxIBs1pW51EazzSCBTD
fnN0YBgGYtCjK+O/HXHB5Wdib5rbU0UUH+D1fbxjLLj+l70ioboGi7Snow==
-----END PUBLIC KEY-----
20 changes: 20 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package main

import (
"flag"
"fmt"

"github.com/wistefan/did-helper/did"
"go.uber.org/zap"
)

Expand All @@ -9,5 +13,21 @@ func init() {
}

func main() {
var path string
var password string

flag.StringVar(&path, "keystorePath", "", "Path to the keystore to be read.")
flag.StringVar(&password, "keystorePassword", "", "Password for the keystore.")

flag.Parse()

zap.L().Sugar().Infof("Path to the keystore: %s", path, "Password to be used: %s", password)

did, err := did.GetDIDKeyFromECPKCS12(path, password)

if err != nil {
fmt.Println("Was not able to extract did. Err: ", err)
} else {
fmt.Println("Did key is: ", did)
}
}

0 comments on commit d61870e

Please sign in to comment.