{"modulePath":"github.com/UnityTech/client-go","version":"v11.0.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cert\n\n## Constants\n\n```go\nconst (\n\t// CertificateBlockType is a possible value for pem.Block.Type.\n\tCertificateBlockType = \"CERTIFICATE\"\n\t// CertificateRequestBlockType is a possible value for pem.Block.Type.\n\tCertificateRequestBlockType = \"CERTIFICATE REQUEST\"\n)\n```\n\n## Functions\n\n```go\nfunc CanReadCertAndKey(certPath, keyPath string) (bool, error)\n```\nCanReadCertAndKey returns true if the certificate and key files already exists, otherwise returns false. If lost one of cert and key, returns error.\n\n```go\nfunc CertsFromFile(file string) ([]*x509.Certificate, error)\n```\nCertsFromFile returns the x509.Certificates contained in the given PEM-encoded file. Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates\n\n```go\nfunc GenerateSelfSignedCertKey(host string, alternateIPs []net.IP, alternateDNS []string) ([]byte, []byte, error)\n```\nGenerateSelfSignedCertKey creates a self-signed certificate and key for the given host. Host may be an IP or a DNS name You may also specify additional subject alt names (either ip or dns names) for the certificate.\n\n```go\nfunc GenerateSelfSignedCertKeyWithFixtures(host string, alternateIPs []net.IP, alternateDNS []string, fixtureDirectory string) ([]byte, []byte, error)\n```\nGenerateSelfSignedCertKeyWithFixtures creates a self-signed certificate and key for the given host. Host may be an IP or a DNS name. You may also specify additional subject alt names (either ip or dns names) for the certificate.\n\nIf fixtureDirectory is non-empty, it is a directory path which can contain pre-generated certs. The format is: \\\u003chost\u003e\\_\\\u003cip\u003e-\\\u003cip\u003e\\_\\\u003calternateDNS\u003e-\\\u003calternateDNS\u003e.crt \\\u003chost\u003e\\_\\\u003cip\u003e-\\\u003cip\u003e\\_\\\u003calternateDNS\u003e-\\\u003calternateDNS\u003e.key Certs/keys not existing in that directory are created.\n\n```go\nfunc MakeCSR(privateKey interface{}, subject *pkix.Name, dnsSANs []string, ipSANs []net.IP) (csr []byte, err error)\n```\nMakeCSR generates a PEM-encoded CSR using the supplied private key, subject, and SANs. All key types that are implemented via crypto.Signer are supported (This includes \\*rsa.PrivateKey and \\*ecdsa.PrivateKey.)\n\n```go\nfunc MakeCSRFromTemplate(privateKey interface{}, template *x509.CertificateRequest) ([]byte, error)\n```\nMakeCSRFromTemplate generates a PEM-encoded CSR using the supplied private key and certificate request as a template. All key types that are implemented via crypto.Signer are supported (This includes \\*rsa.PrivateKey and \\*ecdsa.PrivateKey.)\n\n```go\nfunc NewPool(filename string) (*x509.CertPool, error)\n```\nNewPool returns an x509.CertPool containing the certificates in the given PEM-encoded file. Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates\n\n```go\nfunc NewSelfSignedCACert(cfg Config, key crypto.Signer) (*x509.Certificate, error)\n```\nNewSelfSignedCACert creates a CA certificate\n\n```go\nfunc ParseCertsPEM(pemCerts []byte) ([]*x509.Certificate, error)\n```\nParseCertsPEM returns the x509.Certificates contained in the given PEM-encoded byte array Returns an error if a certificate could not be parsed, or if the data does not contain any certificates\n\n```go\nfunc WriteCert(certPath string, data []byte) error\n```\nWriteCert writes the pem-encoded certificate data to certPath. The certificate file will be created with file mode 0644. If the certificate file already exists, it will be overwritten. The parent directory of the certPath will be created as needed with file mode 0755.\n\n## Types\n\n```go\ntype AltNames struct {\n\tDNSNames []string\n\tIPs      []net.IP\n}\n```\nAltNames contains the domain names and IP addresses that will be added to the API Server's x509 certificate SubAltNames field. The values will be passed directly to the x509.Certificate object.\n\n```go\ntype Config struct {\n\tCommonName   string\n\tOrganization []string\n\tAltNames     AltNames\n\tUsages       []x509.ExtKeyUsage\n}\n```\nConfig contains the basic fields required for creating a certificate\n\n","path":"github.com/UnityTech/client-go/util/cert","name":"cert","synopsis":"","isRedistributable":true}
