1 .TH "hx509 certificate functions" 3 "11 Jan 2012" "Version 1.5.2" "Heimdalx509library" \" -*- nroff -*-
5 hx509 certificate functions \-
10 .RI "int \fBhx509_cert_init\fP (hx509_context context, const Certificate *c, hx509_cert *cert)"
13 .RI "int \fBhx509_cert_init_data\fP (hx509_context context, const void *ptr, size_t len, hx509_cert *cert)"
16 .RI "void \fBhx509_cert_free\fP (hx509_cert cert)"
19 .RI "hx509_cert \fBhx509_cert_ref\fP (hx509_cert cert)"
22 .RI "void \fBhx509_verify_ctx_f_allow_default_trustanchors\fP (hx509_verify_ctx ctx, int boolean)"
25 .RI "int \fBhx509_cert_find_subjectAltName_otherName\fP (hx509_context context, hx509_cert cert, const heim_oid *oid, hx509_octet_string_list *list)"
28 .RI "int \fBhx509_cert_cmp\fP (hx509_cert p, hx509_cert q)"
31 .RI "int \fBhx509_cert_get_issuer\fP (hx509_cert p, hx509_name *name)"
34 .RI "int \fBhx509_cert_get_subject\fP (hx509_cert p, hx509_name *name)"
37 .RI "int \fBhx509_cert_get_base_subject\fP (hx509_context context, hx509_cert c, hx509_name *name)"
40 .RI "int \fBhx509_cert_get_serialnumber\fP (hx509_cert p, heim_integer *i)"
43 .RI "time_t \fBhx509_cert_get_notBefore\fP (hx509_cert p)"
46 .RI "time_t \fBhx509_cert_get_notAfter\fP (hx509_cert p)"
49 .RI "int \fBhx509_cert_get_SPKI\fP (hx509_context context, hx509_cert p, SubjectPublicKeyInfo *spki)"
52 .RI "int \fBhx509_cert_get_SPKI_AlgorithmIdentifier\fP (hx509_context context, hx509_cert p, AlgorithmIdentifier *alg)"
55 .RI "int \fBhx509_cert_get_issuer_unique_id\fP (hx509_context context, hx509_cert p, heim_bit_string *issuer)"
58 .RI "int \fBhx509_cert_get_subject_unique_id\fP (hx509_context context, hx509_cert p, heim_bit_string *subject)"
61 .RI "int \fBhx509_verify_hostname\fP (hx509_context context, const hx509_cert cert, int flags, hx509_hostname_type type, const char *hostname, const struct sockaddr *sa, int sa_size)"
64 .RI "hx509_cert_attribute \fBhx509_cert_get_attribute\fP (hx509_cert cert, const heim_oid *oid)"
67 .RI "int \fBhx509_cert_set_friendly_name\fP (hx509_cert cert, const char *name)"
70 .RI "const char * \fBhx509_cert_get_friendly_name\fP (hx509_cert cert)"
73 .RI "int \fBhx509_query_alloc\fP (hx509_context context, hx509_query **q)"
76 .RI "void \fBhx509_query_match_option\fP (hx509_query *q, hx509_query_option option)"
79 .RI "int \fBhx509_query_match_issuer_serial\fP (hx509_query *q, const Name *issuer, const heim_integer *serialNumber)"
82 .RI "int \fBhx509_query_match_friendly_name\fP (hx509_query *q, const char *name)"
85 .RI "int \fBhx509_query_match_eku\fP (hx509_query *q, const heim_oid *eku)"
88 .RI "int \fBhx509_query_match_cmp_func\fP (hx509_query *q, int(*func)(hx509_context, hx509_cert, void *), void *ctx)"
91 .RI "void \fBhx509_query_free\fP (hx509_context context, hx509_query *q)"
94 .RI "void \fBhx509_query_statistic_file\fP (hx509_context context, const char *fn)"
97 .RI "void \fBhx509_query_unparse_stats\fP (hx509_context context, int printtype, FILE *out)"
100 .RI "int \fBhx509_cert_check_eku\fP (hx509_context context, hx509_cert cert, const heim_oid *eku, int allow_any_eku)"
103 .RI "int \fBhx509_cert_binary\fP (hx509_context context, hx509_cert c, heim_octet_string *os)"
106 .RI "int \fBhx509_print_cert\fP (hx509_context context, hx509_cert cert, FILE *out)"
109 .SH "Detailed Description"
111 See the \fBThe basic certificate\fP for description and examples.
112 .SH "Function Documentation"
114 .SS "int hx509_cert_binary (hx509_context context, hx509_cert c, heim_octet_string * os)"
116 Encodes the hx509 certificate as a DER encode binary.
120 \fIcontext\fP A hx509 context.
122 \fIc\fP the certificate to encode.
124 \fIos\fP the encode certificate, set to NULL, 0 on case of error. Free the os->data with \fBhx509_xfree()\fP.
129 An hx509 error code, see \fBhx509_get_error_string()\fP.
133 .SS "int hx509_cert_check_eku (hx509_context context, hx509_cert cert, const heim_oid * eku, int allow_any_eku)"
135 Check the extended key usage on the hx509 certificate.
139 \fIcontext\fP A hx509 context.
141 \fIcert\fP A hx509 context.
143 \fIeku\fP the EKU to check for
145 \fIallow_any_eku\fP if the any EKU is set, allow that to be a substitute.
150 An hx509 error code, see \fBhx509_get_error_string()\fP.
154 .SS "int hx509_cert_cmp (hx509_cert p, hx509_cert q)"
156 Compare to hx509 certificate object, useful for sorting.
160 \fIp\fP a hx509 certificate object.
162 \fIq\fP a hx509 certificate object.
167 0 the objects are the same, returns > 0 is p is 'larger' then q, < 0 if p is 'smaller' then q.
171 .SS "int hx509_cert_find_subjectAltName_otherName (hx509_context context, hx509_cert cert, const heim_oid * oid, hx509_octet_string_list * list)"
173 Return a list of subjectAltNames specified by oid in the certificate. On error the
175 The returned list of octet string should be freed with \fBhx509_free_octet_string_list()\fP.
179 \fIcontext\fP A hx509 context.
181 \fIcert\fP a hx509 certificate object.
183 \fIoid\fP an oid to for SubjectAltName.
185 \fIlist\fP list of matching SubjectAltName.
190 An hx509 error code, see \fBhx509_get_error_string()\fP.
194 .SS "void hx509_cert_free (hx509_cert cert)"
196 Free reference to the hx509 certificate object, if the refcounter reaches 0, the object if freed. Its allowed to pass in NULL.
200 \fIcert\fP the cert to free.
204 .SS "hx509_cert_attribute hx509_cert_get_attribute (hx509_cert cert, const heim_oid * oid)"
206 Get an external attribute for the certificate, examples are friendly name and id.
210 \fIcert\fP hx509 certificate object to search
212 \fIoid\fP an oid to search for.
217 an hx509_cert_attribute, only valid as long as the certificate is referenced.
221 .SS "int hx509_cert_get_base_subject (hx509_context context, hx509_cert c, hx509_name * name)"
223 Return the name of the base subject of the hx509 certificate. If the certiicate is a verified proxy certificate, the this function return the base certificate (root of the proxy chain). If the proxy certificate is not verified with the base certificate HX509_PROXY_CERTIFICATE_NOT_CANONICALIZED is returned.
227 \fIcontext\fP a hx509 context.
229 \fIc\fP a hx509 certificate object.
231 \fIname\fP a pointer to a hx509 name, should be freed by \fBhx509_name_free()\fP. See also \fBhx509_cert_get_subject()\fP.
236 An hx509 error code, see \fBhx509_get_error_string()\fP.
240 .SS "const char* hx509_cert_get_friendly_name (hx509_cert cert)"
242 Get friendly name of the certificate.
246 \fIcert\fP cert to get the friendly name from.
251 an friendly name or NULL if there is. The friendly name is only valid as long as the certificate is referenced.
255 .SS "int hx509_cert_get_issuer (hx509_cert p, hx509_name * name)"
257 Return the name of the issuer of the hx509 certificate.
261 \fIp\fP a hx509 certificate object.
263 \fIname\fP a pointer to a hx509 name, should be freed by \fBhx509_name_free()\fP.
268 An hx509 error code, see \fBhx509_get_error_string()\fP.
272 .SS "int hx509_cert_get_issuer_unique_id (hx509_context context, hx509_cert p, heim_bit_string * issuer)"
274 Get a copy of the Issuer Unique ID
278 \fIcontext\fP a hx509_context
280 \fIp\fP a hx509 certificate
282 \fIissuer\fP the issuer id returned, free with der_free_bit_string()
287 An hx509 error code, see \fBhx509_get_error_string()\fP. The error code HX509_EXTENSION_NOT_FOUND is returned if the certificate doesn't have a issuerUniqueID
291 .SS "time_t hx509_cert_get_notAfter (hx509_cert p)"
293 Get notAfter time of the certificate.
297 \fIp\fP a hx509 certificate object.
302 return not after time.
306 .SS "time_t hx509_cert_get_notBefore (hx509_cert p)"
308 Get notBefore time of the certificate.
312 \fIp\fP a hx509 certificate object.
317 return not before time
321 .SS "int hx509_cert_get_serialnumber (hx509_cert p, heim_integer * i)"
323 Get serial number of the certificate.
327 \fIp\fP a hx509 certificate object.
329 \fIi\fP serial number, should be freed ith der_free_heim_integer().
334 An hx509 error code, see \fBhx509_get_error_string()\fP.
338 .SS "int hx509_cert_get_SPKI (hx509_context context, hx509_cert p, SubjectPublicKeyInfo * spki)"
340 Get the SubjectPublicKeyInfo structure from the hx509 certificate.
344 \fIcontext\fP a hx509 context.
346 \fIp\fP a hx509 certificate object.
348 \fIspki\fP SubjectPublicKeyInfo, should be freed with free_SubjectPublicKeyInfo().
353 An hx509 error code, see \fBhx509_get_error_string()\fP.
357 .SS "int hx509_cert_get_SPKI_AlgorithmIdentifier (hx509_context context, hx509_cert p, AlgorithmIdentifier * alg)"
359 Get the AlgorithmIdentifier from the hx509 certificate.
363 \fIcontext\fP a hx509 context.
365 \fIp\fP a hx509 certificate object.
367 \fIalg\fP AlgorithmIdentifier, should be freed with free_AlgorithmIdentifier(). The algorithmidentifier is typicly rsaEncryption, or id-ecPublicKey, or some other public key mechanism.
372 An hx509 error code, see \fBhx509_get_error_string()\fP.
376 .SS "int hx509_cert_get_subject (hx509_cert p, hx509_name * name)"
378 Return the name of the subject of the hx509 certificate.
382 \fIp\fP a hx509 certificate object.
384 \fIname\fP a pointer to a hx509 name, should be freed by \fBhx509_name_free()\fP. See also \fBhx509_cert_get_base_subject()\fP.
389 An hx509 error code, see \fBhx509_get_error_string()\fP.
393 .SS "int hx509_cert_get_subject_unique_id (hx509_context context, hx509_cert p, heim_bit_string * subject)"
395 Get a copy of the Subect Unique ID
399 \fIcontext\fP a hx509_context
401 \fIp\fP a hx509 certificate
403 \fIsubject\fP the subject id returned, free with der_free_bit_string()
408 An hx509 error code, see \fBhx509_get_error_string()\fP. The error code HX509_EXTENSION_NOT_FOUND is returned if the certificate doesn't have a subjectUniqueID
412 .SS "int hx509_cert_init (hx509_context context, const Certificate * c, hx509_cert * cert)"
414 Allocate and init an hx509 certificate object from the decoded certificate `c´.
418 \fIcontext\fP A hx509 context.
427 Returns an hx509 error code.
431 .SS "int hx509_cert_init_data (hx509_context context, const void * ptr, size_t len, hx509_cert * cert)"
433 Just like \fBhx509_cert_init()\fP, but instead of a decode certificate takes an pointer and length to a memory region that contains a DER/BER encoded certificate.
435 If the memory region doesn't contain just the certificate and nothing more the function will fail with HX509_EXTRA_DATA_AFTER_STRUCTURE.
439 \fIcontext\fP A hx509 context.
441 \fIptr\fP pointer to memory region containing encoded certificate.
443 \fIlen\fP length of memory region.
445 \fIcert\fP a return pointer to a hx509 certificate object, will contain NULL on error.
450 An hx509 error code, see \fBhx509_get_error_string()\fP.
454 .SS "hx509_cert hx509_cert_ref (hx509_cert cert)"
456 Add a reference to a hx509 certificate object.
460 \fIcert\fP a pointer to an hx509 certificate object.
465 the same object as is passed in.
469 .SS "int hx509_cert_set_friendly_name (hx509_cert cert, const char * name)"
471 Set the friendly name on the certificate.
475 \fIcert\fP The certificate to set the friendly name on
477 \fIname\fP Friendly name.
482 An hx509 error code, see \fBhx509_get_error_string()\fP.
486 .SS "int hx509_print_cert (hx509_context context, hx509_cert cert, FILE * out)"
488 Print a simple representation of a certificate
492 \fIcontext\fP A hx509 context, can be NULL
494 \fIcert\fP certificate to print
496 \fIout\fP the stdio output stream, if NULL, stdout is used
505 .SS "int hx509_query_alloc (hx509_context context, hx509_query ** q)"
507 Allocate an query controller. Free using \fBhx509_query_free()\fP.
511 \fIcontext\fP A hx509 context.
513 \fIq\fP return pointer to a hx509_query.
518 An hx509 error code, see \fBhx509_get_error_string()\fP.
522 .SS "void hx509_query_free (hx509_context context, hx509_query * q)"
524 Free the query controller.
528 \fIcontext\fP A hx509 context.
530 \fIq\fP a pointer to the query controller.
534 .SS "int hx509_query_match_cmp_func (hx509_query * q, int(*)(hx509_context, hx509_cert, void *) func, void * ctx)"
536 Set the query controller to match using a specific match function.
540 \fIq\fP a hx509 query controller.
542 \fIfunc\fP function to use for matching, if the argument is NULL, the match function is removed.
544 \fIctx\fP context passed to the function.
549 An hx509 error code, see \fBhx509_get_error_string()\fP.
553 .SS "int hx509_query_match_eku (hx509_query * q, const heim_oid * eku)"
555 Set the query controller to require an one specific EKU (extended key usage). Any previous EKU matching is overwitten. If NULL is passed in as the eku, the EKU requirement is reset.
559 \fIq\fP a hx509 query controller.
561 \fIeku\fP an EKU to match on.
566 An hx509 error code, see \fBhx509_get_error_string()\fP.
570 .SS "int hx509_query_match_friendly_name (hx509_query * q, const char * name)"
572 Set the query controller to match on a friendly name
576 \fIq\fP a hx509 query controller.
578 \fIname\fP a friendly name to match on
583 An hx509 error code, see \fBhx509_get_error_string()\fP.
587 .SS "int hx509_query_match_issuer_serial (hx509_query * q, const Name * issuer, const heim_integer * serialNumber)"
589 Set the issuer and serial number of match in the query controller. The function make copies of the isser and serial number.
593 \fIq\fP a hx509 query controller
595 \fIissuer\fP issuer to search for
597 \fIserialNumber\fP the serialNumber of the issuer.
602 An hx509 error code, see \fBhx509_get_error_string()\fP.
606 .SS "void hx509_query_match_option (hx509_query * q, hx509_query_option option)"
608 Set match options for the hx509 query controller.
612 \fIq\fP query controller.
614 \fIoption\fP options to control the query controller.
619 An hx509 error code, see \fBhx509_get_error_string()\fP.
623 .SS "void hx509_query_statistic_file (hx509_context context, const char * fn)"
625 Set a statistic file for the query statistics.
629 \fIcontext\fP A hx509 context.
631 \fIfn\fP statistics file name
635 .SS "void hx509_query_unparse_stats (hx509_context context, int printtype, FILE * out)"
637 Unparse the statistics file and print the result on a FILE descriptor.
641 \fIcontext\fP A hx509 context.
643 \fIprinttype\fP tyep to print
645 \fIout\fP the FILE to write the data on.
649 .SS "void hx509_verify_ctx_f_allow_default_trustanchors (hx509_verify_ctx ctx, int boolean)"
651 Allow using the operating system builtin trust anchors if no other trust anchors are configured.
655 \fIctx\fP a verification context
657 \fIboolean\fP if non zero, useing the operating systems builtin trust anchors.
662 An hx509 error code, see \fBhx509_get_error_string()\fP.
666 .SS "int hx509_verify_hostname (hx509_context context, const hx509_cert cert, int flags, hx509_hostname_type type, const char * hostname, const struct sockaddr * sa, int sa_size)"
668 Verify that the certificate is allowed to be used for the hostname and address.
672 \fIcontext\fP A hx509 context.
674 \fIcert\fP the certificate to match with
676 \fIflags\fP Flags to modify the behavior:
678 HX509_VHN_F_ALLOW_NO_MATCH no match is ok
681 \fItype\fP type of hostname:
683 HX509_HN_HOSTNAME for plain hostname.
685 HX509_HN_DNSSRV for DNS SRV names.
688 \fIhostname\fP the hostname to check
690 \fIsa\fP address of the host
692 \fIsa_size\fP length of address
697 An hx509 error code, see \fBhx509_get_error_string()\fP.