4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/types.h>
34 #include <openssl/ssl.h>
35 #include <openssl/err.h>
37 #include <boot_http.h>
40 extern const char *hstrerror(int);
43 static const char *errlist
[] = {
44 /* EHTTP_BADARG */ "One or more arguments are not valid",
45 /* EHTTP_NOMEM */ "Insufficient memory",
46 /* EHTTP_CONCLOSED */ "SSL connection is closed (but maybe not the"
47 " underlying connection)",
48 /* EHTTP_UNEXPECTED */ "SSL connection returned unexpected error",
49 /* EHTTP_EOFERR */ "Unexpected/premature EOF",
50 /* EHTTP_NOCERT */ "No certificate was presented",
51 /* EHTTP_NOMATCH */ "'Peername' doesn't match 'host' or no "
53 /* EHTTP_NODATA */ "No data was returned",
54 /* EHTTP_NOT_1_1 */ "Not a HTTP/1.1 server",
55 /* EHTTP_BADHDR */ "Invalid header",
56 /* EHTTP_OORANGE */ "Request header line out of range",
57 /* EHTTP_NORESP */ "No response or partial response received",
58 /* EHTTP_BADRESP */ "Bad response or error response returned",
59 /* EHTTP_NOHEADER */ "Chunked header expected but not found",
60 /* EHTTP_NOBOUNDARY */ "Boundary line expected but not found",
61 /* EHTTP_NOTMULTI */ "This is not a multipart transfer",
62 /* EHTTP_BADSIZE */ "Could not determine msg body size"
64 static int nerrs
= { sizeof (errlist
) / sizeof (errlist
[0]) };
67 * http_errorstr - print the error associated with the source and errorcode
70 * errsrc - Which library caused the error (as returned by
72 * error - The error code returned
75 * Pointer to error string for this error.
78 http_errorstr(uint_t errsrc
, ulong_t error
)
80 char const *msg
= NULL
;
82 static char message
[128];
86 msg
= strerror(error
);
88 msg
= "Unknown system error";
91 if (error
== 0 || error
> nerrs
)
92 msg
= "Unknown libhttp error";
94 msg
= errlist
[error
- 1];
98 (void) sprintf(message
, "Host retrieval error %lu\n", error
);
101 msg
= hstrerror(error
);
104 case ERRSRC_VERIFERR
:
105 msg
= X509_verify_cert_error_string(error
);
108 msg
= ERR_error_string(error
, NULL
);
111 msg
= "Unknown error";