clicert.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <refentry id="refclicert">
  2. <refmeta>
  3. <refentrytitle>ne_ssl_client_cert</refentrytitle>
  4. <manvolnum>3</manvolnum>
  5. </refmeta>
  6. <refnamediv>
  7. <refname id="ne_ssl_clicert_read">ne_ssl_clicert_read</refname>
  8. <refname id="ne_ssl_clicert_name">ne_ssl_clicert_name</refname>
  9. <refname id="ne_ssl_clicert_encrypted">ne_ssl_clicert_encrypted</refname>
  10. <refname id="ne_ssl_clicert_decrypt">ne_ssl_clicert_decrypt</refname>
  11. <refname id="ne_ssl_clicert_owner">ne_ssl_clicert_owner</refname>
  12. <refname id="ne_ssl_clicert_free">ne_ssl_clicert_free</refname>
  13. <refpurpose>SSL client certificate handling</refpurpose>
  14. </refnamediv>
  15. <refsynopsisdiv>
  16. <funcsynopsis>
  17. <funcsynopsisinfo>#include &lt;ne_ssl.h&gt;</funcsynopsisinfo>
  18. <funcprototype>
  19. <funcdef>ne_ssl_client_cert *<function>ne_ssl_clicert_read</function></funcdef>
  20. <paramdef>const char *<parameter>filename</parameter></paramdef>
  21. </funcprototype>
  22. <funcprototype>
  23. <funcdef>const char *<function>ne_ssl_clicert_name</function></funcdef>
  24. <paramdef>const ne_ssl_client_cert *<parameter>ccert</parameter></paramdef>
  25. </funcprototype>
  26. <funcprototype>
  27. <funcdef>int <function>ne_ssl_clicert_encrypted</function></funcdef>
  28. <paramdef>const ne_ssl_client_cert *<parameter>ccert</parameter></paramdef>
  29. </funcprototype>
  30. <funcprototype>
  31. <funcdef>int <function>ne_ssl_clicert_decrypt</function></funcdef>
  32. <paramdef>ne_ssl_client_cert *<parameter>ccert</parameter></paramdef>
  33. <paramdef>const char *<parameter>password</parameter></paramdef>
  34. </funcprototype>
  35. <funcprototype>
  36. <funcdef>const ne_ssl_certificate *<function>ne_ssl_clicert_owner</function></funcdef>
  37. <paramdef>const ne_ssl_client_cert *<parameter>ccert</parameter></paramdef>
  38. </funcprototype>
  39. <funcprototype>
  40. <funcdef>void <function>ne_ssl_clicert_free</function></funcdef>
  41. <paramdef>ne_ssl_client_cert *<parameter>ccert</parameter></paramdef>
  42. </funcprototype>
  43. </funcsynopsis>
  44. </refsynopsisdiv>
  45. <refsect1>
  46. <title>Description</title>
  47. <para>The <function>ne_ssl_clicert_read</function> function reads
  48. a <firstterm>client certificate</firstterm> from a
  49. PKCS#12-formatted file, and returns an
  50. <type>ne_ssl_client_cert</type> object. If the client
  51. certificate is encrypted, it must be decrypted before it is used.
  52. An <type>ne_ssl_client_cert</type> object holds a client
  53. certificate and the associated private key, not just a
  54. certificate; the term "<glossterm>client certificate</glossterm>"
  55. will used to refer to this pair.</para>
  56. <para>A client certificate can be in one of two states:
  57. <emphasis>encrypted</emphasis> or <emphasis>decrypted</emphasis>.
  58. The <function>ne_ssl_clicert_encrypted</function> function will
  59. return non-zero if the client certificate is in the
  60. <emphasis>encrypted</emphasis> state. A client certificate object
  61. returned by <function>ne_ssl_clicert_read</function> may be
  62. initially in either state, depending on whether the file was
  63. encrypted or not.</para>
  64. <para><function>ne_ssl_clicert_decrypt</function> can be used to
  65. decrypt a client certificate using the appropriate password. This
  66. function must only be called if the object is in the
  67. <emphasis>encrypted</emphasis> state; if decryption fails, the
  68. certificate state does not change, so decryption can be attempted
  69. more than once using different passwords.</para>
  70. <para>A client certificate can be given a "friendly name" when it
  71. is created; <function>ne_ssl_clicert_name</function> will return
  72. this name (or &null; if no friendly name was specified).
  73. <function>ne_ssl_clicert_name</function> can be used when the
  74. client certificate is in either the encrypted or decrypted state,
  75. and will return the same string for the lifetime of the
  76. object.</para>
  77. <para>The function <function>ne_ssl_clicert_owner</function>
  78. returns the certificate part of the client certificate; it must
  79. only be called if the client certificate is in the
  80. <emphasis>decrypted</emphasis> state.</para>
  81. <para>When the client certificate is no longer needed, the
  82. <function>ne_ssl_clicert_free</function> function should be used
  83. to destroy the object.</para>
  84. </refsect1>
  85. <refsect1>
  86. <title>Return value</title>
  87. <para><function>ne_ssl_clicert_read</function> returns a client
  88. certificate object, or &null; if the file could not be read.
  89. <function>ne_ssl_clicert_encrypted</function> returns zero if the
  90. object is in the decrypted state, or non-zero if it is in the
  91. encrypted state. <function>ne_ssl_clicert_name</function> returns
  92. a &nul;-terminated friendly name string, or &null;.
  93. <function>ne_ssl_clicert_owner</function> returns a certificate
  94. object.</para>
  95. </refsect1>
  96. <refsect1>
  97. <title>Examples</title>
  98. <para>The following code reads a client certificate and decrypts
  99. it if necessary, then loads it into an HTTP session.</para>
  100. <programlisting>ne_ssl_client_cert *ccert;
  101. ccert = ne_ssl_clicert_read("/path/to/client.p12");
  102. if (ccert == NULL) {
  103. /* handle error... */
  104. } else if (ne_ssl_clicert_encrypted(ccert)) {
  105. char *password = prompt_for_password();
  106. if (ne_ssl_clicert_decrypt(ccert, password)) {
  107. /* could not decrypt! handle error... */
  108. }
  109. }
  110. ne_ssl_set_clicert(sess, ccert);
  111. </programlisting>
  112. </refsect1>
  113. <refsect1>
  114. <title>See also</title>
  115. <para><xref linkend="ne_ssl_cert_read"/></para>
  116. </refsect1>
  117. </refentry>