github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/internal/cert/add_cert_linux.go (about)

     1  //go:build linux
     2  
     3  package cert
     4  
     5  import (
     6  	"log"
     7  
     8  	"github.com/quickfeed/quickfeed/kit/sh"
     9  )
    10  
    11  // AddTrustedCert adds given the certificate the user's keychain.
    12  func AddTrustedCert(certFile string) error {
    13  	const certPath = "/usr/local/share/ca-certificates/"
    14  	out, err := sh.OutputA("sudo", "cp", certFile, certPath)
    15  	if out != "" {
    16  		log.Print(out)
    17  	}
    18  	if err != nil {
    19  		return err
    20  	}
    21  	out, err = sh.Output("sudo update-ca-certificates")
    22  	if out != "" {
    23  		log.Print(out)
    24  	}
    25  	if err != nil {
    26  		return err
    27  	}
    28  	return nil
    29  }