chore: setup workflow
All checks were successful
Cross-Compile Binaries / cross-compile (push) Successful in 37s
All checks were successful
Cross-Compile Binaries / cross-compile (push) Successful in 37s
This commit is contained in:
29
.gitea/workflows/cross-compile.yaml
Normal file
29
.gitea/workflows/cross-compile.yaml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: Cross-Compile Binaries
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cross-compile:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
- name: Checkout and pull the code
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup the Go programming language
|
||||||
|
uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: 'stable'
|
||||||
|
|
||||||
|
- name: Install the Fyne cross-compile package
|
||||||
|
run: go install github.com/fyne-io/fyne-cross@latest
|
||||||
|
|
||||||
|
- name: checkout
|
||||||
|
run: ls -l
|
||||||
29
generator.go
29
generator.go
@@ -1,26 +1,37 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"log"
|
|
||||||
|
|
||||||
"software.sslmate.com/src/go-pkcs12"
|
"software.sslmate.com/src/go-pkcs12"
|
||||||
)
|
)
|
||||||
|
|
||||||
func generatePassword(n int) string {
|
const passChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*?"
|
||||||
for i := range n {
|
|
||||||
log.Println(i)
|
func generatePassword(n int) (string, error) {
|
||||||
|
bytes := make([]byte, n)
|
||||||
|
_, err := rand.Read(bytes)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
}
|
}
|
||||||
return "DefaultPass"
|
|
||||||
|
for i, b := range bytes {
|
||||||
|
bytes[i] = passChars[int(b)%len(passChars)]
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func generatePKCS12(pKey any, cert *x509.Certificate, caCerts []*x509.Certificate) (string, []byte) {
|
func generatePKCS12(pKey any, cert *x509.Certificate, caCerts []*x509.Certificate) (string, []byte, error) {
|
||||||
pfxPass := generatePassword(50)
|
pfxPass, err := generatePassword(50)
|
||||||
|
if err != nil {
|
||||||
|
return "Failed to create password", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
pfxData, err := pkcs12.Modern.Encode(pKey, cert, caCerts, pfxPass)
|
pfxData, err := pkcs12.Modern.Encode(pKey, cert, caCerts, pfxPass)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "Failed to create PFX with given data.", nil
|
return "Failed to create PFX with given data.", nil, err
|
||||||
} else {
|
} else {
|
||||||
return "PKCS12 generated seemingly succesfully.", pfxData
|
return "PKCS generated succesfully, password: " + pfxPass, pfxData, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,11 +12,11 @@ func checkPublicKey(cert *x509.Certificate) {
|
|||||||
switch pub := cert.PublicKey.(type) {
|
switch pub := cert.PublicKey.(type) {
|
||||||
|
|
||||||
case *rsa.PublicKey:
|
case *rsa.PublicKey:
|
||||||
fmt.Println("RSA key:", pub.N.BitLen(), "bits")
|
log.Println("RSA key:", pub.N.BitLen(), "bits")
|
||||||
case *ecdsa.PublicKey:
|
case *ecdsa.PublicKey:
|
||||||
fmt.Println("ECDSA key:", pub.Curve.Params().Name)
|
log.Println("ECDSA key:", pub.Curve.Params().Name)
|
||||||
case ed25519.PublicKey:
|
case ed25519.PublicKey:
|
||||||
fmt.Println("Ed25519 key")
|
log.Println("Ed25519 key")
|
||||||
default:
|
default:
|
||||||
log.Fatal("Unsupported public key type")
|
log.Fatal("Unsupported public key type")
|
||||||
}
|
}
|
||||||
|
|||||||
35
main.go
35
main.go
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
|
"image/color"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
certpair "pkcs-generator/modules/certpairs"
|
certpair "pkcs-generator/modules/certpairs"
|
||||||
@@ -10,10 +11,12 @@ import (
|
|||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
|
"fyne.io/fyne/v2/canvas"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
"fyne.io/fyne/v2/dialog"
|
"fyne.io/fyne/v2/dialog"
|
||||||
"fyne.io/fyne/v2/layout"
|
"fyne.io/fyne/v2/layout"
|
||||||
"fyne.io/fyne/v2/storage"
|
"fyne.io/fyne/v2/storage"
|
||||||
|
"fyne.io/fyne/v2/theme"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,6 +29,8 @@ var (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
a := app.NewWithID("nl.systemec.pkcs-generator")
|
a := app.NewWithID("nl.systemec.pkcs-generator")
|
||||||
|
a.Settings().SetTheme(theme.DefaultTheme())
|
||||||
|
|
||||||
w := a.NewWindow("Systemec PKCS-Generator")
|
w := a.NewWindow("Systemec PKCS-Generator")
|
||||||
w.Resize(windowSize)
|
w.Resize(windowSize)
|
||||||
|
|
||||||
@@ -86,9 +91,16 @@ func main() {
|
|||||||
})
|
})
|
||||||
caRadio.SetSelected("New Sectigo (2025+)") // default
|
caRadio.SetSelected("New Sectigo (2025+)") // default
|
||||||
|
|
||||||
// Make a text grid to display text.
|
// Multiline entry
|
||||||
grid := widget.NewTextGrid()
|
textLabl := widget.NewLabel("Status will appear here...")
|
||||||
grid.SetText("Status will appear here.")
|
textLabl.Selectable = true
|
||||||
|
|
||||||
|
border := canvas.NewRectangle(color.Transparent)
|
||||||
|
border.StrokeColor = color.RGBA{255, 255, 255, 255}
|
||||||
|
border.StrokeWidth = 2
|
||||||
|
border.CornerRadius = 5
|
||||||
|
|
||||||
|
statusBox := container.NewStack(border, textLabl)
|
||||||
|
|
||||||
actionBtn := widget.NewButton("Generate", func() {
|
actionBtn := widget.NewButton("Generate", func() {
|
||||||
files := []string{keyPath, certPath}
|
files := []string{keyPath, certPath}
|
||||||
@@ -110,7 +122,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !allPresent {
|
if !allPresent {
|
||||||
grid.SetText("One or more files missing!")
|
textLabl.SetText("One or more files missing!")
|
||||||
log.Println("One or more files missing!")
|
log.Println("One or more files missing!")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -119,7 +131,7 @@ func main() {
|
|||||||
|
|
||||||
if pfxData == nil {
|
if pfxData == nil {
|
||||||
log.Println(respText)
|
log.Println(respText)
|
||||||
grid.SetText(respText)
|
textLabl.SetText(respText)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,10 +155,9 @@ func main() {
|
|||||||
|
|
||||||
writer.Close()
|
writer.Close()
|
||||||
|
|
||||||
var dnText string = "PKCS file saved to: " + writer.URI().Path()
|
var dnText string = "PKCS file saved to: " + writer.URI().Path() + "\n" + respText
|
||||||
|
|
||||||
log.Println(dnText)
|
textLabl.SetText(dnText)
|
||||||
grid.SetText(dnText)
|
|
||||||
}, w)
|
}, w)
|
||||||
svDialog.Resize(windowSize)
|
svDialog.Resize(windowSize)
|
||||||
|
|
||||||
@@ -176,7 +187,7 @@ func main() {
|
|||||||
widget.NewLabel("\n"),
|
widget.NewLabel("\n"),
|
||||||
container.New(layout.NewGridLayout(2), radioLabel1, caRadio),
|
container.New(layout.NewGridLayout(2), radioLabel1, caRadio),
|
||||||
layout.NewSpacer(), // optional flexible space
|
layout.NewSpacer(), // optional flexible space
|
||||||
grid, // Add the referenced text grid container
|
statusBox, // Add the referenced text container
|
||||||
widget.NewLabel(""), // Add empty line for space
|
widget.NewLabel(""), // Add empty line for space
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -257,5 +268,9 @@ func integrityCheckAndGo(keyPath, certPath, caRootString, caCertString string) (
|
|||||||
|
|
||||||
caCertList := []*x509.Certificate{caCert, rootCert}
|
caCertList := []*x509.Certificate{caCert, rootCert}
|
||||||
|
|
||||||
return generatePKCS12(key, cert, caCertList)
|
msg, pfxData, err := generatePKCS12(key, cert, caCertList)
|
||||||
|
if err != nil {
|
||||||
|
return msg, nil
|
||||||
|
}
|
||||||
|
return msg, pfxData
|
||||||
}
|
}
|
||||||
|
|||||||
2
scripts/compile_linux.sh
Normal file
2
scripts/compile_linux.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
go build
|
||||||
Reference in New Issue
Block a user