From aa713af15300b0f47b6d13698247d8d526a725ac Mon Sep 17 00:00:00 2001 From: Urko Date: Mon, 6 Mar 2023 18:00:40 +0100 Subject: [PATCH] feat: add readme --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8a0f6f1 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# go-grpc-certificate + +## Problem's context +I've got some trouble while I want to use gRPC through TLS certificates. I've created a certificated from a .pem key file which had +a password and I couldn't use it through `go` standard library. I found a solution based on this **[SO answer](https://stackoverflow.com/a/56131169/6329540)** to this **[question](https://stackoverflow.com/questions/56129533/tls-with-certificate-private-key-and-pass-phrase/56131169#comment132834574_56131169)** + +## Solution +I've decided to use **[openssl](https://www.openssl.org/docs/manmaster/man1/)** to achieve this task as far as I was not able to found a solution in go standard library. + +## Installation requirements +I've used this version on development. So we should check if it backwards compatible. +```shell +$ openssl version +OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023) +``` + + +## How to use +In your `go` project you just have to type in your terminal: +```shell +$ go get gitea.urkob.com/urko/go-grpc-certificate +``` + +Then place in your code like this +```go +package main + +// here should be defined your imports +certcreds "gitea.urkob.com/urko/go-grpc-certificate/pkg/credentials" + + +func main() { + certPath := "place your certificate path" + certKeyPath := "place your key file path" + keyPassword := "place your key password here" + + creds, err = certcreds.CredentialsFromKeyWithPasswd( + certPah, certKeyPath, keyPassword, + ) + if err != nil { + log.Fatalf("Failed loading certificates: %v\n", err) + } +} +``` \ No newline at end of file