# AUTHOR <EMAIL@ADDRESS>, YEAR.
# 
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Defensive Coding Guide\n"
"POT-Creation-Date: 2013-03-12T03:19:44\n"
"PO-Revision-Date: 2013-03-19 15:33+0000\n"
"Last-Translator: Automatically generated\n"
"Language-Team: Chinese (Taiwan) <trans-zh_TW@lists.fedoraproject.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: zh_TW\n"
"Plural-Forms: nplurals=1; plural=0;\n"

#. Tag: programlisting
#, no-c-format
msgid ""
"\n"
"// Wrap the POSIX file descriptor.  This is an internal NSPR\n"
"// function, but it is very unlikely to change.\n"
"PRFileDesc* nspr = PR_ImportTCPSocket(sockfd);\n"
"sockfd = -1; // Has been taken over by NSPR.\n"
"\n"
"// Add the SSL layer.\n"
"{\n"
"  PRFileDesc *model = PR_NewTCPSocket();\n"
"  PRFileDesc *newfd = SSL_ImportFD(NULL, model);\n"
"  if (newfd == NULL) {\n"
"    const PRErrorCode err = PR_GetError();\n"
"    fprintf(stderr, \"error: NSPR error code %d: %s\n"
"\",\n"
"\t      err, PR_ErrorToName(err));\n"
"    exit(1);\n"
"  }\n"
"  model = newfd;\n"
"  newfd = NULL;\n"
"  if (SSL_OptionSet(model, SSL_ENABLE_SSL2, PR_FALSE) != SECSuccess) {\n"
"    const PRErrorCode err = PR_GetError();\n"
"    fprintf(stderr, \"error: set SSL_ENABLE_SSL2 error %d: %s\n"
"\",\n"
"\t      err, PR_ErrorToName(err));\n"
"    exit(1);\n"
"  }\n"
"  if (SSL_OptionSet(model, SSL_V2_COMPATIBLE_HELLO, PR_FALSE) != SECSuccess) {\n"
"    const PRErrorCode err = PR_GetError();\n"
"    fprintf(stderr, \"error: set SSL_V2_COMPATIBLE_HELLO error %d: %s\n"
"\",\n"
"\t      err, PR_ErrorToName(err));\n"
"    exit(1);\n"
"  }\n"
"  if (SSL_OptionSet(model, SSL_ENABLE_DEFLATE, PR_FALSE) != SECSuccess) {\n"
"    const PRErrorCode err = PR_GetError();\n"
"    fprintf(stderr, \"error: set SSL_ENABLE_DEFLATE error %d: %s\n"
"\",\n"
"\t      err, PR_ErrorToName(err));\n"
"    exit(1);\n"
"  }\n"
"\n"
"  // Disable all ciphers (except RC4-based ciphers, for backwards\n"
"  // compatibility).\n"
"  const PRUint16 *const ciphers = SSL_GetImplementedCiphers();\n"
"  for (unsigned i = 0; i &lt; SSL_GetNumImplementedCiphers(); i++) {\n"
"    if (ciphers[i] != SSL_RSA_WITH_RC4_128_SHA\n"
"\t  &amp;&amp; ciphers[i] != SSL_RSA_WITH_RC4_128_MD5) {\n"
"\tif (SSL_CipherPrefSet(model, ciphers[i], PR_FALSE) != SECSuccess) {\n"
"\t  const PRErrorCode err = PR_GetError();\n"
"\t  fprintf(stderr, \"error: disable cipher %u: error %d: %s\n"
"\",\n"
"\t\t  (unsigned)ciphers[i], err, PR_ErrorToName(err));\n"
"\t  exit(1);\n"
"\t}\n"
"    }\n"
"  }\n"
"\n"
"  // Enable the strong ciphers.\n"
"  for (const PRUint16 *p = good_ciphers; *p != SSL_NULL_WITH_NULL_NULL;\n"
"\t ++p) {\n"
"    if (SSL_CipherPrefSet(model, *p, PR_TRUE) != SECSuccess) {\n"
"\tconst PRErrorCode err = PR_GetError();\n"
"\tfprintf(stderr, \"error: enable cipher %u: error %d: %s\n"
"\",\n"
"\t\t(unsigned)*p, err, PR_ErrorToName(err));\n"
"\texit(1);\n"
"    }\n"
"  }\n"
"\n"
"  // Allow overriding invalid certificate.\n"
"  if (SSL_BadCertHook(model, bad_certificate, (char *)host) != SECSuccess) {\n"
"    const PRErrorCode err = PR_GetError();\n"
"    fprintf(stderr, \"error: SSL_BadCertHook error %d: %s\n"
"\",\n"
"\t      err, PR_ErrorToName(err));\n"
"    exit(1);\n"
"  }\n"
"\n"
"  newfd = SSL_ImportFD(model, nspr);\n"
"  if (newfd == NULL) {\n"
"    const PRErrorCode err = PR_GetError();\n"
"    fprintf(stderr, \"error: SSL_ImportFD error %d: %s\n"
"\",\n"
"\t      err, PR_ErrorToName(err));\n"
"    exit(1);\n"
"  }\n"
"  nspr = newfd;\n"
"  PR_Close(model);\n"
"}\n"
"\n"
"// Perform the handshake.\n"
"if (SSL_ResetHandshake(nspr, PR_FALSE) != SECSuccess) {\n"
"  const PRErrorCode err = PR_GetError();\n"
"  fprintf(stderr, \"error: SSL_ResetHandshake error %d: %s\n"
"\",\n"
"\t    err, PR_ErrorToName(err));\n"
"  exit(1);\n"
"}\n"
"if (SSL_SetURL(nspr, host) != SECSuccess) {\n"
"  const PRErrorCode err = PR_GetError();\n"
"  fprintf(stderr, \"error: SSL_SetURL error %d: %s\n"
"\",\n"
"\t    err, PR_ErrorToName(err));\n"
"  exit(1);\n"
"}\n"
"if (SSL_ForceHandshake(nspr) != SECSuccess) {\n"
"  const PRErrorCode err = PR_GetError();\n"
"  fprintf(stderr, \"error: SSL_ForceHandshake error %d: %s\n"
"\",\n"
"\t    err, PR_ErrorToName(err));\n"
"  exit(1);\n"
"}\n"
msgstr ""
