{"modulePath":"github.com/blockfi/cfssl","version":"v1.6.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errors\n\nPackage errors provides error types returned in CF SSL.\n\n1\\. Type Error is intended for errors produced by CF SSL packages. It formats to a json object that consists of an error message and a 4-digit code for error reasoning.\n\nExample: {\"code\":1002, \"message\": \"Failed to decode certificate\"}\n\nThe index of codes are listed below:\n\n\t1XXX: CertificateError\n\t    1000: Unknown\n\t    1001: ReadFailed\n\t    1002: DecodeFailed\n\t    1003: ParseFailed\n\t    1100: SelfSigned\n\t    12XX: VerifyFailed\n\t        121X: CertificateInvalid\n\t            1210: NotAuthorizedToSign\n\t            1211: Expired\n\t            1212: CANotAuthorizedForThisName\n\t            1213: TooManyIntermediates\n\t            1214: IncompatibleUsage\n\t        1220: UnknownAuthority\n\t2XXX: PrivatekeyError\n\t    2000: Unknown\n\t    2001: ReadFailed\n\t    2002: DecodeFailed\n\t    2003: ParseFailed\n\t    2100: Encrypted\n\t    2200: NotRSA\n\t    2300: KeyMismatch\n\t    2400: GenerationFailed\n\t    2500: Unavailable\n\t3XXX: IntermediatesError\n\t4XXX: RootError\n\t5XXX: PolicyError\n\t    5100: NoKeyUsages\n\t    5200: InvalidPolicy\n\t    5300: InvalidRequest\n\t    5400: UnknownProfile\n\t    6XXX: DialError\n\n2\\. Type HttpError is intended for CF SSL API to consume. It contains a HTTP status code that will be read and returned by the API server.\n\n## Constants\n\n```go\nconst (\n\tBundleExpiringBit      int = 1 \u003c\u003c iota // 0x01\n\tBundleNotUbiquitousBit                 // 0x02\n)\n```\nWarning code for a success\n\n```go\nconst (\n\t// PrecertSubmissionFailed occurs when submitting a precertificate to\n\t// a log server fails\n\tPrecertSubmissionFailed = 100 * (iota + 1)\n\t// CTClientConstructionFailed occurs when the construction of a new\n\t// github.com/google/certificate-transparency client fails.\n\tCTClientConstructionFailed\n\t// PrecertMissingPoison occurs when a precert is passed to SignFromPrecert\n\t// and is missing the CT poison extension.\n\tPrecertMissingPoison\n\t// PrecertInvalidPoison occurs when a precert is passed to SignFromPrecert\n\t// and has a invalid CT poison extension value or the extension is not\n\t// critical.\n\tPrecertInvalidPoison\n)\n```\nCertificate transparency related errors specified with CTError\n\n```go\nconst (\n\t// InsertionFailed occurs when a SQL insert query failes to complete.\n\tInsertionFailed = 100 * (iota + 1)\n\t// RecordNotFound occurs when a SQL query targeting on one unique\n\t// record failes to update the specified row in the table.\n\tRecordNotFound\n)\n```\nCertificate persistence related errors specified with CertStoreError\n\n## Types\n\n```go\ntype Category int\n```\nCategory is the most significant digit of the error code.\n\n```go\nconst (\n\t// Success indicates no error occurred.\n\tSuccess Category = 1000 * iota // 0XXX\n\n\t// CertificateError indicates a fault in a certificate.\n\tCertificateError // 1XXX\n\n\t// PrivateKeyError indicates a fault in a private key.\n\tPrivateKeyError // 2XXX\n\n\t// IntermediatesError indicates a fault in an intermediate.\n\tIntermediatesError // 3XXX\n\n\t// RootError indicates a fault in a root.\n\tRootError // 4XXX\n\n\t// PolicyError indicates an error arising from a malformed or\n\t// non-existent policy, or a breach of policy.\n\tPolicyError // 5XXX\n\n\t// DialError indicates a network fault.\n\tDialError // 6XXX\n\n\t// APIClientError indicates a problem with the API client.\n\tAPIClientError // 7XXX\n\n\t// OCSPError indicates a problem with OCSP signing\n\tOCSPError // 8XXX\n\n\t// CSRError indicates a problem with CSR parsing\n\tCSRError // 9XXX\n\n\t// CTError indicates a problem with the certificate transparency process\n\tCTError // 10XXX\n\n\t// CertStoreError indicates a problem with the certificate store\n\tCertStoreError // 11XXX\n)\n```\n\n```go\ntype Error struct {\n\tErrorCode int    `json:\"code\"`\n\tMessage   string `json:\"message\"`\n}\n```\nError is the error type usually returned by functions in CF SSL package. It contains a 4-digit error code where the most significant digit describes the category where the error occurred and the rest 3 digits describe the specific error reason.\n\n```go\nfunc New(category Category, reason Reason) *Error\n```\nNew returns an error that contains  an error code and message derived from the given category, reason. Currently, to avoid confusion, it is not allowed to create an error of category Success\n\n```go\nfunc Wrap(category Category, reason Reason, err error) *Error\n```\nWrap returns an error that contains the given error and an error code derived from the given category, reason and the error. Currently, to avoid confusion, it is not allowed to create an error of category Success\n\n```go\nfunc (e *Error) Error() string\n```\nThe error interface implementation, which formats to a JSON object string.\n\n```go\ntype HTTPError struct {\n\tStatusCode int\n\t// contains filtered or unexported fields\n}\n```\nHTTPError is an augmented error with a HTTP status code.\n\n```go\nfunc NewBadRequest(err error) *HTTPError\n```\nNewBadRequest creates a HttpError with the given error and error code 400.\n\n```go\nfunc NewBadRequestMissingParameter(s string) *HTTPError\n```\nNewBadRequestMissingParameter returns a 400 HttpError as a required parameter is missing in the HTTP request.\n\n```go\nfunc NewBadRequestString(s string) *HTTPError\n```\nNewBadRequestString returns a HttpError with the supplied message and error code 400.\n\n```go\nfunc NewBadRequestUnwantedParameter(s string) *HTTPError\n```\nNewBadRequestUnwantedParameter returns a 400 HttpError as a unnecessary parameter is present in the HTTP request.\n\n```go\nfunc NewMethodNotAllowed(method string) *HTTPError\n```\nNewMethodNotAllowed returns an appropriate error in the case that an HTTP client uses an invalid method (i.e. a GET in place of a POST) on an API endpoint.\n\n```go\nfunc (e *HTTPError) Error() string\n```\nError implements the error interface.\n\n```go\ntype Reason int\n```\nReason is the last 3 digits of the error code.\n\n```go\nconst (\n\tUnknown      Reason = iota // X000\n\tReadFailed                 // X001\n\tDecodeFailed               // X002\n\tParseFailed                // X003\n)\n```\nParsing errors\n\n```go\nconst (\n\t// SelfSigned indicates that a certificate is self-signed and\n\t// cannot be used in the manner being attempted.\n\tSelfSigned Reason = 100 * (iota + 1) // Code 11XX\n\n\t// VerifyFailed is an X.509 verification failure. The least two\n\t// significant digits of 12XX is determined as the actual x509\n\t// error is examined.\n\tVerifyFailed // Code 12XX\n\n\t// BadRequest indicates that the certificate request is invalid.\n\tBadRequest // Code 13XX\n\n\t// MissingSerial indicates that the profile specified\n\t// 'ClientProvidesSerialNumbers', but the SignRequest did not include a serial\n\t// number.\n\tMissingSerial // Code 14XX\n)\n```\nThe following represent certificate non-parsing errors, and must be specified along with CertificateError.\n\n```go\nconst (\n\t// Encrypted indicates that the private key is a PKCS #8 encrypted\n\t// private key. At this time, CFSSL does not support decrypting\n\t// these keys.\n\tEncrypted Reason = 100 * (iota + 1) //21XX\n\n\t// NotRSAOrECC indicates that they key is not an RSA or ECC\n\t// private key; these are the only two private key types supported\n\t// at this time by CFSSL.\n\tNotRSAOrECC //22XX\n\n\t// KeyMismatch indicates that the private key does not match\n\t// the public key or certificate being presented with the key.\n\tKeyMismatch //23XX\n\n\t// GenerationFailed indicates that a private key could not\n\t// be generated.\n\tGenerationFailed //24XX\n\n\t// Unavailable indicates that a private key mechanism (such as\n\t// PKCS #11) was requested but support for that mechanism is\n\t// not available.\n\tUnavailable\n)\n```\nThe following represent private-key non-parsing errors, and must be specified with PrivateKeyError.\n\n```go\nconst (\n\t// NoKeyUsages indicates that the profile does not permit any\n\t// key usages for the certificate.\n\tNoKeyUsages Reason = 100 * (iota + 1) // 51XX\n\n\t// InvalidPolicy indicates that policy being requested is not\n\t// a valid policy or does not exist.\n\tInvalidPolicy // 52XX\n\n\t// InvalidRequest indicates a certificate request violated the\n\t// constraints of the policy being applied to the request.\n\tInvalidRequest // 53XX\n\n\t// UnknownProfile indicates that the profile does not exist.\n\tUnknownProfile // 54XX\n\n\tUnmatchedWhitelist // 55xx\n)\n```\nThe following are policy-related non-parsing errors, and must be specified along with PolicyError.\n\n```go\nconst (\n\t// AuthenticationFailure occurs when the client is unable\n\t// to obtain an authentication token for the request.\n\tAuthenticationFailure Reason = 100 * (iota + 1)\n\n\t// JSONError wraps an encoding/json error.\n\tJSONError\n\n\t// IOError wraps an io/ioutil error.\n\tIOError\n\n\t// ClientHTTPError wraps a net/http error.\n\tClientHTTPError\n\n\t// ServerRequestFailed covers any other failures from the API\n\t// client.\n\tServerRequestFailed\n)\n```\nThe following are API client related errors, and should be specified with APIClientError.\n\n```go\nconst (\n\t// IssuerMismatch ocurs when the certificate in the OCSP signing\n\t// request was not issued by the CA that this responder responds for.\n\tIssuerMismatch Reason = 100 * (iota + 1) // 81XX\n\n\t// InvalidStatus occurs when the OCSP signing requests includes an\n\t// invalid value for the certificate status.\n\tInvalidStatus\n)\n```\nThe following are OCSP related errors, and should be specified with OCSPError\n\n```go\nconst (\n\tNone Reason = iota\n)\n```\nNone is a non-specified error.\n\n","path":"github.com/blockfi/cfssl/errors","name":"errors","synopsis":"Package errors provides error types returned in CF SSL.","isRedistributable":true}
