github.com/blend/go-sdk@v1.20220411.3/examples/certutil/create_certs/main.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package main
     9  
    10  import (
    11  	"fmt"
    12  	"os"
    13  
    14  	"github.com/blend/go-sdk/certutil"
    15  	"github.com/blend/go-sdk/uuid"
    16  )
    17  
    18  func main() {
    19  	ca, _ := certutil.CreateCertificateAuthority(certutil.OptSubjectCommonName("go-sdk certificate authority"))
    20  
    21  	ca.WriteCertPem(os.Stdout)
    22  	fmt.Println()
    23  
    24  	ca.WriteKeyPem(os.Stdout)
    25  	fmt.Println()
    26  
    27  	certBundle, _ := certutil.CreateServer(uuid.V4().String(), ca)
    28  
    29  	certBundle.WriteCertPem(os.Stdout)
    30  	fmt.Println()
    31  	certBundle.WriteKeyPem(os.Stdout)
    32  	fmt.Println()
    33  }