ne_ssl_clicert_read.3 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. '\" t
  2. .\" Title: ne_ssl_client_cert
  3. .\" Author:
  4. .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
  5. .\" Date: 15 July 2025
  6. .\" Manual: neon API reference
  7. .\" Source: neon 0.35.0
  8. .\" Language: English
  9. .\"
  10. .TH "NE_SSL_CLIENT_CERT" "3" "15 July 2025" "neon 0.35.0" "neon API reference"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. ne_ssl_clicert_read, ne_ssl_clicert_import, ne_ssl_clicert_fromuri, ne_ssl_clicert_name, ne_ssl_clicert_encrypted, ne_ssl_clicert_decrypt, ne_ssl_clicert_owner, ne_ssl_clicert_free \- SSL client certificate handling
  32. .SH "SYNOPSIS"
  33. .sp
  34. .ft B
  35. .nf
  36. #include <ne_ssl\&.h>
  37. .fi
  38. .ft
  39. .HP \w'ne_ssl_client_cert\ *ne_ssl_clicert_read('u
  40. .BI "ne_ssl_client_cert *ne_ssl_clicert_read(const\ char\ *" "filename" ");"
  41. .HP \w'ne_ssl_client_cert\ *ne_ssl_clicert_import('u
  42. .BI "ne_ssl_client_cert *ne_ssl_clicert_import(const\ unsigned\ char\ *" "filename" ", size_t\ " "buflen" ");"
  43. .HP \w'ne_ssl_client_cert\ *ne_ssl_clicert_fromuri('u
  44. .BI "ne_ssl_client_cert *ne_ssl_clicert_fromuri(const\ char\ *" "uri" ", unsigned\ " "flags" ");"
  45. .HP \w'const\ char\ *ne_ssl_clicert_name('u
  46. .BI "const char *ne_ssl_clicert_name(const\ ne_ssl_client_cert\ *" "ccert" ");"
  47. .HP \w'int\ ne_ssl_clicert_encrypted('u
  48. .BI "int ne_ssl_clicert_encrypted(const\ ne_ssl_client_cert\ *" "ccert" ");"
  49. .HP \w'int\ ne_ssl_clicert_decrypt('u
  50. .BI "int ne_ssl_clicert_decrypt(ne_ssl_client_cert\ *" "ccert" ", const\ char\ *" "password" ");"
  51. .HP \w'const\ ne_ssl_certificate\ *ne_ssl_clicert_owner('u
  52. .BI "const ne_ssl_certificate *ne_ssl_clicert_owner(const\ ne_ssl_client_cert\ *" "ccert" ");"
  53. .HP \w'void\ ne_ssl_clicert_free('u
  54. .BI "void ne_ssl_clicert_free(ne_ssl_client_cert\ *" "ccert" ");"
  55. .SH "DESCRIPTION"
  56. .PP
  57. The
  58. \fBne_ssl_clicert_read\fR
  59. function reads a
  60. client certificate
  61. from a PKCS#12\-formatted file, and returns an
  62. \fBne_ssl_client_cert\fR
  63. object\&. The
  64. \fBne_ssl_clicert_import\fR
  65. function reads a client certificate from a memory buffer using the PKCS#12 format\&. The
  66. \fBne_ssl_clicert_fromuri\fR
  67. function loads a client certificate from a URI\&. URI schemes supported are defined by the SSL/TLS toolkit, and may include
  68. \m[blue]\fBPKCS#11 URIs\fR\m[]\&\s-2\u[1]\d\s+2\&.
  69. .PP
  70. A
  71. \fBne_ssl_client_cert\fR
  72. object represents both a client certificate and the associated private key; the term "client certificate" is used here to refer to this pair\&. A client certificate object loaded by any of the above functions can be in one of two states:
  73. \fIencrypted\fR
  74. or
  75. \fIdecrypted\fR\&. The
  76. \fBne_ssl_clicert_encrypted\fR
  77. function will return non\-zero if the client certificate is in the
  78. \fIencrypted\fR
  79. state\&.
  80. .PP
  81. A client certificate
  82. \fImust\fR
  83. be in the decrypted state before it is associated with a session\&.
  84. \fBne_ssl_clicert_decrypt\fR
  85. can be used to decrypt a client certificate using the appropriate password\&. This function must only be called if the object is in the
  86. \fIencrypted\fR
  87. state; if decryption fails, the certificate state does not change, so decryption can be attempted more than once using different passwords\&.
  88. .PP
  89. A client certificate can be given a "friendly name" when it is created;
  90. \fBne_ssl_clicert_name\fR
  91. will return this name (or
  92. NULL
  93. if no friendly name was specified)\&.
  94. \fBne_ssl_clicert_name\fR
  95. can be used when the client certificate is in either the encrypted or decrypted state, and will return the same string for the lifetime of the object\&.
  96. .PP
  97. The function
  98. \fBne_ssl_clicert_owner\fR
  99. returns the certificate part of the client certificate; it must only be called if the client certificate is in the
  100. \fIdecrypted\fR
  101. state\&.
  102. .PP
  103. When the client certificate object is no longer needed, the
  104. \fBne_ssl_clicert_free\fR
  105. function should be used to destroy the object\&.
  106. .SH "RETURN VALUE"
  107. .PP
  108. \fBne_ssl_clicert_read\fR,
  109. \fBne_ssl_clicert_import\fR
  110. and
  111. \fBne_ssl_clicert_fromuri\fR
  112. all return a client certificate object, or
  113. NULL
  114. if the certificate could not be read/imported\&.
  115. \fBne_ssl_clicert_encrypted\fR
  116. returns zero if the object is in the decrypted state, or non\-zero if it is in the encrypted state\&.
  117. \fBne_ssl_clicert_name\fR
  118. returns a
  119. NUL\-terminated friendly name string, or
  120. NULL\&.
  121. \fBne_ssl_clicert_owner\fR
  122. returns a certificate object\&.
  123. .SH "EXAMPLES"
  124. .PP
  125. The following code reads a client certificate and decrypts it if necessary, then loads it into an HTTP session\&.
  126. .sp
  127. .if n \{\
  128. .RS 4
  129. .\}
  130. .nf
  131. ne_ssl_client_cert *ccert;
  132. ccert = ne_ssl_clicert_read("/path/to/client\&.p12");
  133. if (ccert == NULL) {
  134. /* handle error\&.\&.\&. */
  135. } else if (ne_ssl_clicert_encrypted(ccert)) {
  136. char *password = prompt_for_password();
  137. if (ne_ssl_clicert_decrypt(ccert, password)) {
  138. /* could not decrypt! handle error\&.\&.\&. */
  139. }
  140. }
  141. ne_ssl_set_clicert(sess, ccert);
  142. .fi
  143. .if n \{\
  144. .RE
  145. .\}
  146. .SH "HISTORY"
  147. .PP
  148. \fBne_ssl_clicert_import\fR
  149. was added in neon 0\&.30\&.0\&.
  150. \fBne_ssl_clicert_fromuri\fR
  151. was added in neon 0\&.35\&.0\&.
  152. .SH "SEE ALSO"
  153. .PP
  154. ne_ssl_cert_read
  155. .SH "COPYRIGHT"
  156. .br
  157. Copyright \(co 2001-2025 Joe Orton
  158. .br
  159. .SH "REFERENCES"
  160. .IP " 1." 4
  161. PKCS#11 URIs
  162. .RS 4
  163. \%https://www.rfc-editor.org/rfc/rfc7512.html
  164. .RE