1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package confidential_test
import (
"fmt"
"log"
"os"
"github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential"
)
func ExampleNewCredFromCert_pem() {
b, err := os.ReadFile("key.pem")
if err != nil {
log.Fatal(err)
}
// This extracts our public certificates and private key from the PEM file. If it is
// encrypted, the second argument must be password to decode.
certs, priv, err := confidential.CertFromPEM(b, "")
if err != nil {
log.Fatal(err)
}
cred, err := confidential.NewCredFromCert(certs, priv)
if err != nil {
log.Fatal(err)
}
fmt.Println(cred) // Simply here so cred is used, otherwise won't compile.
}
|