1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 2004 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
25 #ifdef HAVE_STRERROR_R
26 # if (!defined(HAVE_POSIX_STRERROR_R) && \
27 !defined(HAVE_GLIBC_STRERROR_R) && \
28 !defined(HAVE_VXWORKS_STRERROR_R)) || \
29 (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
30 (defined(HAVE_GLIBC_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
31 (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R))
32 # error "strerror_r MUST be either POSIX, glibc or vxworks-style"
36 #include <curl/curl.h>
43 #include "curl_printf.h"
44 #include "curl_memory.h"
45 /* The last #include file should be: */
49 curl_easy_strerror(CURLcode error)
51 #ifndef CURL_DISABLE_VERBOSE_STRINGS
56 case CURLE_UNSUPPORTED_PROTOCOL:
57 return "Unsupported protocol";
59 case CURLE_FAILED_INIT:
60 return "Failed initialization";
62 case CURLE_URL_MALFORMAT:
63 return "URL using bad/illegal format or missing URL";
65 case CURLE_NOT_BUILT_IN:
66 return "A requested feature, protocol or option was not found built-in in"
67 " this libcurl due to a build-time decision.";
69 case CURLE_COULDNT_RESOLVE_PROXY:
70 return "Couldn't resolve proxy name";
72 case CURLE_COULDNT_RESOLVE_HOST:
73 return "Couldn't resolve host name";
75 case CURLE_COULDNT_CONNECT:
76 return "Couldn't connect to server";
78 case CURLE_FTP_WEIRD_SERVER_REPLY:
79 return "FTP: weird server reply";
81 case CURLE_REMOTE_ACCESS_DENIED:
82 return "Access denied to remote resource";
84 case CURLE_FTP_ACCEPT_FAILED:
85 return "FTP: The server failed to connect to data port";
87 case CURLE_FTP_ACCEPT_TIMEOUT:
88 return "FTP: Accepting server connect has timed out";
90 case CURLE_FTP_PRET_FAILED:
91 return "FTP: The server did not accept the PRET command.";
93 case CURLE_FTP_WEIRD_PASS_REPLY:
94 return "FTP: unknown PASS reply";
96 case CURLE_FTP_WEIRD_PASV_REPLY:
97 return "FTP: unknown PASV reply";
99 case CURLE_FTP_WEIRD_227_FORMAT:
100 return "FTP: unknown 227 response format";
102 case CURLE_FTP_CANT_GET_HOST:
103 return "FTP: can't figure out the host in the PASV response";
106 return "Error in the HTTP2 framing layer";
108 case CURLE_FTP_COULDNT_SET_TYPE:
109 return "FTP: couldn't set file type";
111 case CURLE_PARTIAL_FILE:
112 return "Transferred a partial file";
114 case CURLE_FTP_COULDNT_RETR_FILE:
115 return "FTP: couldn't retrieve (RETR failed) the specified file";
117 case CURLE_QUOTE_ERROR:
118 return "Quote command returned error";
120 case CURLE_HTTP_RETURNED_ERROR:
121 return "HTTP response code said error";
123 case CURLE_WRITE_ERROR:
124 return "Failed writing received data to disk/application";
126 case CURLE_UPLOAD_FAILED:
127 return "Upload failed (at start/before it took off)";
129 case CURLE_READ_ERROR:
130 return "Failed to open/read local data from file/application";
132 case CURLE_OUT_OF_MEMORY:
133 return "Out of memory";
135 case CURLE_OPERATION_TIMEDOUT:
136 return "Timeout was reached";
138 case CURLE_FTP_PORT_FAILED:
139 return "FTP: command PORT failed";
141 case CURLE_FTP_COULDNT_USE_REST:
142 return "FTP: command REST failed";
144 case CURLE_RANGE_ERROR:
145 return "Requested range was not delivered by the server";
147 case CURLE_HTTP_POST_ERROR:
148 return "Internal problem setting up the POST";
150 case CURLE_SSL_CONNECT_ERROR:
151 return "SSL connect error";
153 case CURLE_BAD_DOWNLOAD_RESUME:
154 return "Couldn't resume download";
156 case CURLE_FILE_COULDNT_READ_FILE:
157 return "Couldn't read a file:// file";
159 case CURLE_LDAP_CANNOT_BIND:
160 return "LDAP: cannot bind";
162 case CURLE_LDAP_SEARCH_FAILED:
163 return "LDAP: search failed";
165 case CURLE_FUNCTION_NOT_FOUND:
166 return "A required function in the library was not found";
168 case CURLE_ABORTED_BY_CALLBACK:
169 return "Operation was aborted by an application callback";
171 case CURLE_BAD_FUNCTION_ARGUMENT:
172 return "A libcurl function was given a bad argument";
174 case CURLE_INTERFACE_FAILED:
175 return "Failed binding local connection end";
177 case CURLE_TOO_MANY_REDIRECTS :
178 return "Number of redirects hit maximum amount";
180 case CURLE_UNKNOWN_OPTION:
181 return "An unknown option was passed in to libcurl";
183 case CURLE_TELNET_OPTION_SYNTAX :
184 return "Malformed telnet option";
186 case CURLE_PEER_FAILED_VERIFICATION:
187 return "SSL peer certificate or SSH remote key was not OK";
189 case CURLE_GOT_NOTHING:
190 return "Server returned nothing (no headers, no data)";
192 case CURLE_SSL_ENGINE_NOTFOUND:
193 return "SSL crypto engine not found";
195 case CURLE_SSL_ENGINE_SETFAILED:
196 return "Can not set SSL crypto engine as default";
198 case CURLE_SSL_ENGINE_INITFAILED:
199 return "Failed to initialise SSL crypto engine";
201 case CURLE_SEND_ERROR:
202 return "Failed sending data to the peer";
204 case CURLE_RECV_ERROR:
205 return "Failure when receiving data from the peer";
207 case CURLE_SSL_CERTPROBLEM:
208 return "Problem with the local SSL certificate";
210 case CURLE_SSL_CIPHER:
211 return "Couldn't use specified SSL cipher";
213 case CURLE_SSL_CACERT:
214 return "Peer certificate cannot be authenticated with given CA "
217 case CURLE_SSL_CACERT_BADFILE:
218 return "Problem with the SSL CA cert (path? access rights?)";
220 case CURLE_BAD_CONTENT_ENCODING:
221 return "Unrecognized or bad HTTP Content or Transfer-Encoding";
223 case CURLE_LDAP_INVALID_URL:
224 return "Invalid LDAP URL";
226 case CURLE_FILESIZE_EXCEEDED:
227 return "Maximum file size exceeded";
229 case CURLE_USE_SSL_FAILED:
230 return "Requested SSL level failed";
232 case CURLE_SSL_SHUTDOWN_FAILED:
233 return "Failed to shut down the SSL connection";
235 case CURLE_SSL_CRL_BADFILE:
236 return "Failed to load CRL file (path? access rights?, format?)";
238 case CURLE_SSL_ISSUER_ERROR:
239 return "Issuer check against peer certificate failed";
241 case CURLE_SEND_FAIL_REWIND:
242 return "Send failed since rewinding of the data stream failed";
244 case CURLE_LOGIN_DENIED:
245 return "Login denied";
247 case CURLE_TFTP_NOTFOUND:
248 return "TFTP: File Not Found";
250 case CURLE_TFTP_PERM:
251 return "TFTP: Access Violation";
253 case CURLE_REMOTE_DISK_FULL:
254 return "Disk full or allocation exceeded";
256 case CURLE_TFTP_ILLEGAL:
257 return "TFTP: Illegal operation";
259 case CURLE_TFTP_UNKNOWNID:
260 return "TFTP: Unknown transfer ID";
262 case CURLE_REMOTE_FILE_EXISTS:
263 return "Remote file already exists";
265 case CURLE_TFTP_NOSUCHUSER:
266 return "TFTP: No such user";
268 case CURLE_CONV_FAILED:
269 return "Conversion failed";
271 case CURLE_CONV_REQD:
272 return "Caller must register CURLOPT_CONV_ callback options";
274 case CURLE_REMOTE_FILE_NOT_FOUND:
275 return "Remote file not found";
278 return "Error in the SSH layer";
281 return "Socket not ready for send/recv";
283 case CURLE_RTSP_CSEQ_ERROR:
284 return "RTSP CSeq mismatch or invalid CSeq";
286 case CURLE_RTSP_SESSION_ERROR:
287 return "RTSP session error";
289 case CURLE_FTP_BAD_FILE_LIST:
290 return "Unable to parse FTP file list";
292 case CURLE_CHUNK_FAILED:
293 return "Chunk callback failed";
295 case CURLE_NO_CONNECTION_AVAILABLE:
296 return "The max connection limit is reached";
298 case CURLE_SSL_PINNEDPUBKEYNOTMATCH:
299 return "SSL public key does not match pinned public key";
301 case CURLE_SSL_INVALIDCERTSTATUS:
302 return "SSL server certificate status verification FAILED";
304 /* error codes not used by current libcurl */
305 case CURLE_OBSOLETE20:
306 case CURLE_OBSOLETE24:
307 case CURLE_OBSOLETE29:
308 case CURLE_OBSOLETE32:
309 case CURLE_OBSOLETE40:
310 case CURLE_OBSOLETE44:
311 case CURLE_OBSOLETE46:
312 case CURLE_OBSOLETE50:
313 case CURLE_OBSOLETE57:
318 * By using a switch, gcc -Wall will complain about enum values
319 * which do not appear, helping keep this function up-to-date.
320 * By using gcc -Wall -Werror, you can't forget.
322 * A table would not have the same benefit. Most compilers will
323 * generate code very similar to a table in any case, so there
324 * is little performance gain from a table. And something is broken
325 * for the user's application, anyways, so does it matter how fast
328 * The line number for the error will be near this comment, which
329 * is why it is here, and not at the start of the switch.
331 return "Unknown error";
341 curl_multi_strerror(CURLMcode error)
343 #ifndef CURL_DISABLE_VERBOSE_STRINGS
345 case CURLM_CALL_MULTI_PERFORM:
346 return "Please call curl_multi_perform() soon";
351 case CURLM_BAD_HANDLE:
352 return "Invalid multi handle";
354 case CURLM_BAD_EASY_HANDLE:
355 return "Invalid easy handle";
357 case CURLM_OUT_OF_MEMORY:
358 return "Out of memory";
360 case CURLM_INTERNAL_ERROR:
361 return "Internal error";
363 case CURLM_BAD_SOCKET:
364 return "Invalid socket argument";
366 case CURLM_UNKNOWN_OPTION:
367 return "Unknown option";
369 case CURLM_ADDED_ALREADY:
370 return "The easy handle is already added to a multi handle";
376 return "Unknown error";
378 if(error == CURLM_OK)
386 curl_share_strerror(CURLSHcode error)
388 #ifndef CURL_DISABLE_VERBOSE_STRINGS
393 case CURLSHE_BAD_OPTION:
394 return "Unknown share option";
397 return "Share currently in use";
399 case CURLSHE_INVALID:
400 return "Invalid share handle";
403 return "Out of memory";
405 case CURLSHE_NOT_BUILT_IN:
406 return "Feature not enabled in this library";
412 return "CURLSHcode unknown";
414 if(error == CURLSHE_OK)
423 /* This function handles most / all (?) Winsock errors cURL is able to produce.
426 get_winsock_error (int err, char *buf, size_t len)
430 #ifndef CURL_DISABLE_VERBOSE_STRINGS
433 p = "Call interrupted";
445 p = "Invalid arguments";
448 p = "Out of file descriptors";
451 p = "Call would block";
455 p = "Blocking call in progress";
458 p = "Descriptor is not a socket";
460 case WSAEDESTADDRREQ:
461 p = "Need destination address";
464 p = "Bad message size";
470 p = "Protocol option is unsupported";
472 case WSAEPROTONOSUPPORT:
473 p = "Protocol is unsupported";
475 case WSAESOCKTNOSUPPORT:
476 p = "Socket is unsupported";
479 p = "Operation not supported";
481 case WSAEAFNOSUPPORT:
482 p = "Address family not supported";
484 case WSAEPFNOSUPPORT:
485 p = "Protocol family not supported";
488 p = "Address already in use";
490 case WSAEADDRNOTAVAIL:
491 p = "Address not available";
497 p = "Network unreachable";
500 p = "Network has been reset";
502 case WSAECONNABORTED:
503 p = "Connection was aborted";
506 p = "Connection was reset";
509 p = "No buffer space";
512 p = "Socket is already connected";
515 p = "Socket is not connected";
518 p = "Socket has been shut down";
520 case WSAETOOMANYREFS:
521 p = "Too many references";
526 case WSAECONNREFUSED:
527 p = "Connection refused";
532 case WSAENAMETOOLONG:
538 case WSAEHOSTUNREACH:
539 p = "Host unreachable";
545 p = "Process limit reached";
548 p = "Too many users";
554 p = "Something is stale";
559 #ifdef WSAEDISCON /* missing in SalfordC! */
564 /* Extended Winsock errors */
566 p = "Winsock library is not ready";
568 case WSANOTINITIALISED:
569 p = "Winsock library not initialised";
571 case WSAVERNOTSUPPORTED:
572 p = "Winsock version not supported";
575 /* getXbyY() errors (already handled in herrmsg):
576 * Authoritative Answer: Host not found */
577 case WSAHOST_NOT_FOUND:
578 p = "Host not found";
581 /* Non-Authoritative: Host not found, or SERVERFAIL */
583 p = "Host not found, try again";
586 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
588 p = "Unrecoverable error in call to nameserver";
591 /* Valid name, no data record of requested type */
593 p = "No data record of requested type";
605 strncpy (buf, p, len);
609 #endif /* USE_WINSOCK */
612 * Our thread-safe and smart strerror() replacement.
614 * The 'err' argument passed in to this function MUST be a true errno number
615 * as reported on this system. We do no range checking on the number before
616 * we pass it to the "number-to-message" conversion function and there might
617 * be systems that don't do proper range checking in there themselves.
619 * We don't do range checking (on systems other than Windows) since there is
620 * no good reliable and portable way to do it.
622 const char *Curl_strerror(struct connectdata *conn, int err)
626 int old_errno = ERRNO;
629 DEBUGASSERT(err >= 0);
631 buf = conn->syserr_buf;
632 max = sizeof(conn->syserr_buf)-1;
642 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
643 LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL);
644 wcstombs(buf, wbuf, max);
647 /* 'sys_nerr' is the maximum errno number, it is not widely portable */
648 if(err >= 0 && err < sys_nerr)
649 strncpy(buf, strerror(err), max);
651 if(!get_winsock_error(err, buf, max) &&
652 !FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
653 LANG_NEUTRAL, buf, (DWORD)max, NULL))
654 snprintf(buf, max, "Unknown error %d (%#x)", err, err);
658 #else /* not USE_WINSOCK coming up */
660 #if defined(HAVE_STRERROR_R) && defined(HAVE_POSIX_STRERROR_R)
662 * The POSIX-style strerror_r() may set errno to ERANGE if insufficient
663 * storage is supplied via 'strerrbuf' and 'buflen' to hold the generated
664 * message string, or EINVAL if 'errnum' is not a valid error number.
666 if(0 != strerror_r(err, buf, max)) {
668 snprintf(buf, max, "Unknown error %d", err);
670 #elif defined(HAVE_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)
672 * The glibc-style strerror_r() only *might* use the buffer we pass to
673 * the function, but it always returns the error message as a pointer,
674 * so we must copy that string unconditionally (if non-NULL).
678 char *msg = strerror_r(err, buffer, sizeof(buffer));
680 strncpy(buf, msg, max);
682 snprintf(buf, max, "Unknown error %d", err);
684 #elif defined(HAVE_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)
686 * The vxworks-style strerror_r() does use the buffer we pass to the function.
687 * The buffer size should be at least NAME_MAX (256)
691 if(OK == strerror_r(err, buffer))
692 strncpy(buf, buffer, max);
694 snprintf(buf, max, "Unknown error %d", err);
698 char *msg = strerror(err);
700 strncpy(buf, msg, max);
702 snprintf(buf, max, "Unknown error %d", err);
706 #endif /* end of ! USE_WINSOCK */
708 buf[max] = '\0'; /* make sure the string is zero terminated */
710 /* strip trailing '\r\n' or '\n'. */
711 if((p = strrchr(buf, '\n')) != NULL && (p - buf) >= 2)
713 if((p = strrchr(buf, '\r')) != NULL && (p - buf) >= 1)
716 if(old_errno != ERRNO)
717 SET_ERRNO(old_errno);
724 * Return error-string for libidn status as returned from idna_to_ascii_lz().
726 const char *Curl_idn_strerror (struct connectdata *conn, int err)
728 #ifdef HAVE_IDNA_STRERROR
730 return idna_strerror((Idna_rc) err);
738 buf = conn->syserr_buf;
739 max = sizeof(conn->syserr_buf)-1;
742 #ifndef CURL_DISABLE_VERBOSE_STRINGS
743 switch ((Idna_rc)err) {
747 case IDNA_STRINGPREP_ERROR:
748 str = "Error in string preparation";
750 case IDNA_PUNYCODE_ERROR:
751 str = "Error in Punycode operation";
753 case IDNA_CONTAINS_NON_LDH:
754 str = "Illegal ASCII characters";
756 case IDNA_CONTAINS_MINUS:
757 str = "Contains minus";
759 case IDNA_INVALID_LENGTH:
760 str = "Invalid output length";
762 case IDNA_NO_ACE_PREFIX:
763 str = "No ACE prefix (\"xn--\")";
765 case IDNA_ROUNDTRIP_VERIFY_ERROR:
766 str = "Round trip verify error";
768 case IDNA_CONTAINS_ACE_PREFIX:
769 str = "Already have ACE prefix (\"xn--\")";
771 case IDNA_ICONV_ERROR:
772 str = "Locale conversion failed";
774 case IDNA_MALLOC_ERROR:
775 str = "Allocation failed";
777 case IDNA_DLOPEN_ERROR:
778 str = "dlopen() error";
781 snprintf(buf, max, "error %d", err);
786 if((Idna_rc)err == IDNA_SUCCESS)
792 strncpy(buf, str, max);
797 #endif /* USE_LIBIDN */
799 #ifdef USE_WINDOWS_SSPI
800 const char *Curl_sspi_strerror (struct connectdata *conn, int err)
802 #ifndef CURL_DISABLE_VERBOSE_STRINGS
804 char msgbuf[sizeof(conn->syserr_buf)];
805 char *p, *str, *msg = NULL;
806 bool msg_formatted = FALSE;
815 outbuf = conn->syserr_buf;
816 outmax = sizeof(conn->syserr_buf)-1;
819 #ifndef CURL_DISABLE_VERBOSE_STRINGS
827 case CRYPT_E_REVOKED:
828 txt = "CRYPT_E_REVOKED";
830 case SEC_E_ALGORITHM_MISMATCH:
831 txt = "SEC_E_ALGORITHM_MISMATCH";
833 case SEC_E_BAD_BINDINGS:
834 txt = "SEC_E_BAD_BINDINGS";
836 case SEC_E_BAD_PKGID:
837 txt = "SEC_E_BAD_PKGID";
839 case SEC_E_BUFFER_TOO_SMALL:
840 txt = "SEC_E_BUFFER_TOO_SMALL";
842 case SEC_E_CANNOT_INSTALL:
843 txt = "SEC_E_CANNOT_INSTALL";
845 case SEC_E_CANNOT_PACK:
846 txt = "SEC_E_CANNOT_PACK";
848 case SEC_E_CERT_EXPIRED:
849 txt = "SEC_E_CERT_EXPIRED";
851 case SEC_E_CERT_UNKNOWN:
852 txt = "SEC_E_CERT_UNKNOWN";
854 case SEC_E_CERT_WRONG_USAGE:
855 txt = "SEC_E_CERT_WRONG_USAGE";
857 case SEC_E_CONTEXT_EXPIRED:
858 txt = "SEC_E_CONTEXT_EXPIRED";
860 case SEC_E_CROSSREALM_DELEGATION_FAILURE:
861 txt = "SEC_E_CROSSREALM_DELEGATION_FAILURE";
863 case SEC_E_CRYPTO_SYSTEM_INVALID:
864 txt = "SEC_E_CRYPTO_SYSTEM_INVALID";
866 case SEC_E_DECRYPT_FAILURE:
867 txt = "SEC_E_DECRYPT_FAILURE";
869 case SEC_E_DELEGATION_POLICY:
870 txt = "SEC_E_DELEGATION_POLICY";
872 case SEC_E_DELEGATION_REQUIRED:
873 txt = "SEC_E_DELEGATION_REQUIRED";
875 case SEC_E_DOWNGRADE_DETECTED:
876 txt = "SEC_E_DOWNGRADE_DETECTED";
878 case SEC_E_ENCRYPT_FAILURE:
879 txt = "SEC_E_ENCRYPT_FAILURE";
881 case SEC_E_ILLEGAL_MESSAGE:
882 txt = "SEC_E_ILLEGAL_MESSAGE";
884 case SEC_E_INCOMPLETE_CREDENTIALS:
885 txt = "SEC_E_INCOMPLETE_CREDENTIALS";
887 case SEC_E_INCOMPLETE_MESSAGE:
888 txt = "SEC_E_INCOMPLETE_MESSAGE";
890 case SEC_E_INSUFFICIENT_MEMORY:
891 txt = "SEC_E_INSUFFICIENT_MEMORY";
893 case SEC_E_INTERNAL_ERROR:
894 txt = "SEC_E_INTERNAL_ERROR";
896 case SEC_E_INVALID_HANDLE:
897 txt = "SEC_E_INVALID_HANDLE";
899 case SEC_E_INVALID_PARAMETER:
900 txt = "SEC_E_INVALID_PARAMETER";
902 case SEC_E_INVALID_TOKEN:
903 txt = "SEC_E_INVALID_TOKEN";
905 case SEC_E_ISSUING_CA_UNTRUSTED:
906 txt = "SEC_E_ISSUING_CA_UNTRUSTED";
908 case SEC_E_ISSUING_CA_UNTRUSTED_KDC:
909 txt = "SEC_E_ISSUING_CA_UNTRUSTED_KDC";
911 case SEC_E_KDC_CERT_EXPIRED:
912 txt = "SEC_E_KDC_CERT_EXPIRED";
914 case SEC_E_KDC_CERT_REVOKED:
915 txt = "SEC_E_KDC_CERT_REVOKED";
917 case SEC_E_KDC_INVALID_REQUEST:
918 txt = "SEC_E_KDC_INVALID_REQUEST";
920 case SEC_E_KDC_UNABLE_TO_REFER:
921 txt = "SEC_E_KDC_UNABLE_TO_REFER";
923 case SEC_E_KDC_UNKNOWN_ETYPE:
924 txt = "SEC_E_KDC_UNKNOWN_ETYPE";
926 case SEC_E_LOGON_DENIED:
927 txt = "SEC_E_LOGON_DENIED";
929 case SEC_E_MAX_REFERRALS_EXCEEDED:
930 txt = "SEC_E_MAX_REFERRALS_EXCEEDED";
932 case SEC_E_MESSAGE_ALTERED:
933 txt = "SEC_E_MESSAGE_ALTERED";
935 case SEC_E_MULTIPLE_ACCOUNTS:
936 txt = "SEC_E_MULTIPLE_ACCOUNTS";
938 case SEC_E_MUST_BE_KDC:
939 txt = "SEC_E_MUST_BE_KDC";
941 case SEC_E_NOT_OWNER:
942 txt = "SEC_E_NOT_OWNER";
944 case SEC_E_NO_AUTHENTICATING_AUTHORITY:
945 txt = "SEC_E_NO_AUTHENTICATING_AUTHORITY";
947 case SEC_E_NO_CREDENTIALS:
948 txt = "SEC_E_NO_CREDENTIALS";
950 case SEC_E_NO_IMPERSONATION:
951 txt = "SEC_E_NO_IMPERSONATION";
953 case SEC_E_NO_IP_ADDRESSES:
954 txt = "SEC_E_NO_IP_ADDRESSES";
956 case SEC_E_NO_KERB_KEY:
957 txt = "SEC_E_NO_KERB_KEY";
959 case SEC_E_NO_PA_DATA:
960 txt = "SEC_E_NO_PA_DATA";
962 case SEC_E_NO_S4U_PROT_SUPPORT:
963 txt = "SEC_E_NO_S4U_PROT_SUPPORT";
965 case SEC_E_NO_TGT_REPLY:
966 txt = "SEC_E_NO_TGT_REPLY";
968 case SEC_E_OUT_OF_SEQUENCE:
969 txt = "SEC_E_OUT_OF_SEQUENCE";
971 case SEC_E_PKINIT_CLIENT_FAILURE:
972 txt = "SEC_E_PKINIT_CLIENT_FAILURE";
974 case SEC_E_PKINIT_NAME_MISMATCH:
975 txt = "SEC_E_PKINIT_NAME_MISMATCH";
977 case SEC_E_POLICY_NLTM_ONLY:
978 txt = "SEC_E_POLICY_NLTM_ONLY";
980 case SEC_E_QOP_NOT_SUPPORTED:
981 txt = "SEC_E_QOP_NOT_SUPPORTED";
983 case SEC_E_REVOCATION_OFFLINE_C:
984 txt = "SEC_E_REVOCATION_OFFLINE_C";
986 case SEC_E_REVOCATION_OFFLINE_KDC:
987 txt = "SEC_E_REVOCATION_OFFLINE_KDC";
989 case SEC_E_SECPKG_NOT_FOUND:
990 txt = "SEC_E_SECPKG_NOT_FOUND";
992 case SEC_E_SECURITY_QOS_FAILED:
993 txt = "SEC_E_SECURITY_QOS_FAILED";
995 case SEC_E_SHUTDOWN_IN_PROGRESS:
996 txt = "SEC_E_SHUTDOWN_IN_PROGRESS";
998 case SEC_E_SMARTCARD_CERT_EXPIRED:
999 txt = "SEC_E_SMARTCARD_CERT_EXPIRED";
1001 case SEC_E_SMARTCARD_CERT_REVOKED:
1002 txt = "SEC_E_SMARTCARD_CERT_REVOKED";
1004 case SEC_E_SMARTCARD_LOGON_REQUIRED:
1005 txt = "SEC_E_SMARTCARD_LOGON_REQUIRED";
1007 case SEC_E_STRONG_CRYPTO_NOT_SUPPORTED:
1008 txt = "SEC_E_STRONG_CRYPTO_NOT_SUPPORTED";
1010 case SEC_E_TARGET_UNKNOWN:
1011 txt = "SEC_E_TARGET_UNKNOWN";
1013 case SEC_E_TIME_SKEW:
1014 txt = "SEC_E_TIME_SKEW";
1016 case SEC_E_TOO_MANY_PRINCIPALS:
1017 txt = "SEC_E_TOO_MANY_PRINCIPALS";
1019 case SEC_E_UNFINISHED_CONTEXT_DELETED:
1020 txt = "SEC_E_UNFINISHED_CONTEXT_DELETED";
1022 case SEC_E_UNKNOWN_CREDENTIALS:
1023 txt = "SEC_E_UNKNOWN_CREDENTIALS";
1025 case SEC_E_UNSUPPORTED_FUNCTION:
1026 txt = "SEC_E_UNSUPPORTED_FUNCTION";
1028 case SEC_E_UNSUPPORTED_PREAUTH:
1029 txt = "SEC_E_UNSUPPORTED_PREAUTH";
1031 case SEC_E_UNTRUSTED_ROOT:
1032 txt = "SEC_E_UNTRUSTED_ROOT";
1034 case SEC_E_WRONG_CREDENTIAL_HANDLE:
1035 txt = "SEC_E_WRONG_CREDENTIAL_HANDLE";
1037 case SEC_E_WRONG_PRINCIPAL:
1038 txt = "SEC_E_WRONG_PRINCIPAL";
1040 case SEC_I_COMPLETE_AND_CONTINUE:
1041 txt = "SEC_I_COMPLETE_AND_CONTINUE";
1043 case SEC_I_COMPLETE_NEEDED:
1044 txt = "SEC_I_COMPLETE_NEEDED";
1046 case SEC_I_CONTEXT_EXPIRED:
1047 txt = "SEC_I_CONTEXT_EXPIRED";
1049 case SEC_I_CONTINUE_NEEDED:
1050 txt = "SEC_I_CONTINUE_NEEDED";
1052 case SEC_I_INCOMPLETE_CREDENTIALS:
1053 txt = "SEC_I_INCOMPLETE_CREDENTIALS";
1055 case SEC_I_LOCAL_LOGON:
1056 txt = "SEC_I_LOCAL_LOGON";
1058 case SEC_I_NO_LSA_CONTEXT:
1059 txt = "SEC_I_NO_LSA_CONTEXT";
1061 case SEC_I_RENEGOTIATE:
1062 txt = "SEC_I_RENEGOTIATE";
1064 case SEC_I_SIGNATURE_NEEDED:
1065 txt = "SEC_I_SIGNATURE_NEEDED";
1068 txt = "Unknown error";
1072 strncpy(outbuf, txt, outmax);
1073 else if(err == SEC_E_ILLEGAL_MESSAGE)
1074 snprintf(outbuf, outmax,
1075 "SEC_E_ILLEGAL_MESSAGE (0x%04X%04X) - This error usually occurs "
1076 "when a fatal SSL/TLS alert is received (e.g. handshake failed). "
1077 "More detail may be available in the Windows System event log.",
1078 (err >> 16) & 0xffff, err & 0xffff);
1081 snprintf(txtbuf, sizeof(txtbuf), "%s (0x%04X%04X)",
1082 txt, (err >> 16) & 0xffff, err & 0xffff);
1083 txtbuf[sizeof(txtbuf)-1] = '\0';
1090 if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
1091 FORMAT_MESSAGE_IGNORE_INSERTS,
1092 NULL, err, LANG_NEUTRAL,
1093 wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) {
1094 wcstombs(msgbuf, wbuf, sizeof(msgbuf)-1);
1095 msg_formatted = TRUE;
1099 if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
1100 FORMAT_MESSAGE_IGNORE_INSERTS,
1101 NULL, err, LANG_NEUTRAL,
1102 msgbuf, sizeof(msgbuf)-1, NULL)) {
1103 msg_formatted = TRUE;
1107 msgbuf[sizeof(msgbuf)-1] = '\0';
1108 /* strip trailing '\r\n' or '\n' */
1109 if((p = strrchr(msgbuf, '\n')) != NULL && (p - msgbuf) >= 2)
1111 if((p = strrchr(msgbuf, '\r')) != NULL && (p - msgbuf) >= 1)
1116 snprintf(outbuf, outmax, "%s - %s", str, msg);
1118 strncpy(outbuf, str, outmax);
1121 if(old_errno != ERRNO)
1122 SET_ERRNO(old_errno);
1131 strncpy(outbuf, txt, outmax);
1135 outbuf[outmax] = '\0';
1139 #endif /* USE_WINDOWS_SSPI */