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

Merge gdsutil and reissuer #1177

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Empty file modified cmd/bffutil/build.sh
100755 → 100644
Empty file.
52 changes: 52 additions & 0 deletions cmd/gdsutil/admin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package main

import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
"os"

"github.com/segmentio/ksuid"
"github.com/urfave/cli/v2"
)

//===========================================================================
// Admin Functions
//===========================================================================

func generateTokenKey(c *cli.Context) (err error) {
// Create ksuid and determine outpath
var keyid ksuid.KSUID
if keyid, err = ksuid.NewRandom(); err != nil {
return cli.Exit(err, 1)
}

var out string
if out = c.String("out"); out == "" {
out = fmt.Sprintf("%s.pem", keyid)
}

// Generate RSA keys using crypto random
var key *rsa.PrivateKey
if key, err = rsa.GenerateKey(rand.Reader, c.Int("size")); err != nil {
return cli.Exit(err, 1)
}

// Open file to PEM encode keys to
var f *os.File
if f, err = os.OpenFile(out, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600); err != nil {
return cli.Exit(err, 1)
}

if err = pem.Encode(f, &pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(key),
}); err != nil {
return cli.Exit(err, 1)
}

fmt.Printf("RSA key id: %s -- saved with PEM encoding to %s\n", keyid, out)
return nil
}
85 changes: 0 additions & 85 deletions cmd/gdsutil/build.sh

This file was deleted.

Loading
Loading