-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT: Extend binary to generate certificates
- Loading branch information
1 parent
ba1c9fe
commit 4c2a2e4
Showing
6 changed files
with
72 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import "github.com/urfave/cli" | ||
|
||
var ( | ||
organizationFlag = cli.StringFlag{ | ||
Name: "organization", | ||
Usage: "This flag specifies the organization name which will generate the certificate", | ||
Value: "MultiversX", | ||
} | ||
dnsFlag = cli.StringFlag{ | ||
Name: "dns", | ||
Usage: "This flag specifies the server's dns for tls connection", | ||
Value: "localhost", | ||
} | ||
availabilityFlag = cli.StringFlag{ | ||
Name: "availability", | ||
Usage: "This flag specifies the certificate's availability in days starting from current timestamp", | ||
Value: "365", | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,64 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
logger "github.com/multiversx/mx-chain-logger-go" | ||
"github.com/multiversx/mx-chain-sovereign-bridge-go/cert" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
var log = logger.GetOrCreate("cert") | ||
|
||
func main() { | ||
|
||
app := cli.NewApp() | ||
app.Name = "Certificate generator" | ||
app.Usage = "Generate certificate (.crt + .pem) for grpc tls connection between server and client.\n" + | ||
"->Certificate Generation: To enable secure communication, generate a certificate pair containing a .crt (certificate) " + | ||
"and a .pem (private key) for both the server and the sovereign nodes (clients). This will facilitate the encryption and " + | ||
"authentication required for the gRPC TLS connection.\n" + | ||
"->Authentication of Clients: The server, acting as the hot wallet binary, should authenticate and validate the sovereign nodes (clients) " + | ||
"attempting to connect. Only trusted clients with the matching certificate will be granted access to interact with the hot wallet binary.\n" + | ||
"->Ensuring Secure Transactions: Utilize the certificate-based authentication mechanism to ensure that only authorized sovereign nodes can access the hot wallet binary. " + | ||
"This step is crucial in maintaining the integrity and security of transactions being sent from the sovereign shards to the main chain.\n" + | ||
"->Ongoing Security Measures: Regularly review and update the certificate mechanism to maintain security. This includes renewal of certificates, " + | ||
"implementing security best practices, and promptly revoking access for compromised or unauthorized clients." | ||
app.Action = generateCertificate | ||
app.Flags = []cli.Flag{ | ||
organizationFlag, | ||
dnsFlag, | ||
availabilityFlag, | ||
} | ||
|
||
err := app.Run(os.Args) | ||
if err != nil { | ||
log.Error(err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
} | ||
|
||
func generateCertificate(ctx *cli.Context) error { | ||
organization := ctx.GlobalString(organizationFlag.Name) | ||
dns := ctx.GlobalString(dnsFlag.Name) | ||
availability := ctx.GlobalInt64(availabilityFlag.Name) | ||
|
||
err := cert.GenerateCertFile(cert.CertificateCfg{ | ||
CertCfg: cert.CertCfg{ | ||
Organization: "MultiversX", | ||
DNSName: "localhost", | ||
Availability: 10, | ||
Organization: organization, | ||
DNSName: dns, | ||
Availability: availability, | ||
}, | ||
CertFileCfg: cert.FileCfg{ | ||
CertFile: "certificate.crt", | ||
PkFile: "private_key.pem", | ||
}, | ||
}) | ||
fmt.Println(err) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Info("generated files successfully") | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters