{"modulePath":"github.com/UnityTech/client-go","version":"v2.0.0+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cert\n\n## Functions\n\n```go\nfunc CanReadCertOrKey(certPath, keyPath string) bool\n```\nCanReadCertOrKey returns true if the certificate or key files already exists, otherwise returns false.\n\n```go\nfunc EncodeCertPEM(cert *x509.Certificate) []byte\n```\nEncodeCertPEM returns PEM-endcoded certificate data\n\n```go\nfunc EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte\n```\nEncodePrivateKeyPEM returns PEM-encoded private key data\n\n```go\nfunc EncodePublicKeyPEM(key *rsa.PublicKey) ([]byte, error)\n```\nEncodePublicKeyPEM returns PEM-endcode public data\n\n```go\nfunc FormatBytesCert(cert []byte) (string, error)\n```\nFormatBytesCert receives byte array certificate and formats in human-readable format\n\n```go\nfunc FormatCert(c *x509.Certificate) string\n```\nFormatCert receives certificate and formats in human-readable format\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 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 MakeEllipticPrivateKeyPEM() ([]byte, error)\n```\nMakeEllipticPrivateKeyPEM creates an ECDSA private key\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 NewPrivateKey() (*rsa.PrivateKey, error)\n```\nNewPrivateKey creates an RSA private key\n\n```go\nfunc NewSelfSignedCACert(cfg Config, key *rsa.PrivateKey) (*x509.Certificate, error)\n```\nNewSelfSignedCACert creates a CA certificate\n\n```go\nfunc NewSignedCert(cfg Config, key *rsa.PrivateKey, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*x509.Certificate, error)\n```\nNewSignedCert creates a signed certificate using the given CA certificate and key\n\n```go\nfunc ParseCSR(obj *certificates.CertificateSigningRequest) (*x509.CertificateRequest, error)\n```\nParseCSR extracts the CSR from the API object and decodes it.\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 ParsePrivateKeyPEM(keyData []byte) (interface{}, error)\n```\nParsePrivateKeyPEM returns a private key parsed from a PEM block in the supplied data. Recognizes PEM blocks for \"EC PRIVATE KEY\" and \"RSA PRIVATE KEY\"\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```go\nfunc WriteKey(keyPath string, data []byte) error\n```\nWriteKey writes the pem-encoded key data to keyPath. The key file will be created with file mode 0600. If the key file already exists, it will be overwritten. The parent directory of the keyPath 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}\n```\nConfig containes the basic fields required for creating a certificate\n\n","path":"github.com/UnityTech/client-go/pkg/util/cert","name":"cert","synopsis":"","isRedistributable":true}
