X509_sign.pod 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. =pod
  2. =head1 NAME
  3. X509_sign, X509_sign_ctx, X509_verify, X509_REQ_sign, X509_REQ_sign_ctx,
  4. X509_REQ_verify, X509_CRL_sign, X509_CRL_sign_ctx, X509_CRL_verify -
  5. sign or verify certificate, certificate request or CRL signature
  6. =head1 SYNOPSIS
  7. #include <openssl/x509.h>
  8. int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
  9. int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
  10. int X509_verify(X509 *a, EVP_PKEY *r);
  11. int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
  12. int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
  13. int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
  14. int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
  15. int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
  16. int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
  17. =head1 DESCRIPTION
  18. X509_sign() signs certificate B<x> using private key B<pkey> and message
  19. digest B<md> and sets the signature in B<x>. X509_sign_ctx() also signs
  20. certificate B<x> but uses the parameters contained in digest context B<ctx>.
  21. X509_verify() verifies the signature of certificate B<x> using public key
  22. B<pkey>. Only the signature is checked: no other checks (such as certificate
  23. chain validity) are performed.
  24. X509_REQ_sign(), X509_REQ_sign_ctx(), X509_REQ_verify(),
  25. X509_CRL_sign(), X509_CRL_sign_ctx() and X509_CRL_verify() sign and verify
  26. certificate requests and CRLs respectively.
  27. =head1 NOTES
  28. X509_sign_ctx() is used where the default parameters for the corresponding
  29. public key and digest are not suitable. It can be used to sign keys using
  30. RSA-PSS for example.
  31. For efficiency reasons and to work around ASN.1 encoding issues the encoding
  32. of the signed portion of a certificate, certificate request and CRL is cached
  33. internally. If the signed portion of the structure is modified the encoding
  34. is not always updated meaning a stale version is sometimes used. This is not
  35. normally a problem because modifying the signed portion will invalidate the
  36. signature and signing will always update the encoding.
  37. =head1 RETURN VALUES
  38. X509_sign(), X509_sign_ctx(), X509_REQ_sign(), X509_REQ_sign_ctx(),
  39. X509_CRL_sign() and X509_CRL_sign_ctx() return the size of the signature
  40. in bytes for success and zero for failure.
  41. X509_verify(), X509_REQ_verify() and X509_CRL_verify() return 1 if the
  42. signature is valid and 0 if the signature check fails. If the signature
  43. could not be checked at all because it was invalid or some other error
  44. occurred then -1 is returned.
  45. =head1 SEE ALSO
  46. L<d2i_X509(3)>,
  47. L<ERR_get_error(3)>,
  48. L<X509_CRL_get0_by_serial(3)>,
  49. L<X509_get0_signature(3)>,
  50. L<X509_get_ext_d2i(3)>,
  51. L<X509_get_extension_flags(3)>,
  52. L<X509_get_pubkey(3)>,
  53. L<X509_get_subject_name(3)>,
  54. L<X509_get_version(3)>,
  55. L<X509_NAME_add_entry_by_txt(3)>,
  56. L<X509_NAME_ENTRY_get_object(3)>,
  57. L<X509_NAME_get_index_by_NID(3)>,
  58. L<X509_NAME_print_ex(3)>,
  59. L<X509_new(3)>,
  60. L<X509V3_get_d2i(3)>,
  61. L<X509_verify_cert(3)>
  62. =head1 HISTORY
  63. The X509_sign(), X509_REQ_sign() and X509_CRL_sign() functions are
  64. available in all versions of OpenSSL.
  65. The X509_sign_ctx(), X509_REQ_sign_ctx()
  66. and X509_CRL_sign_ctx() functions were added OpenSSL 1.0.1.
  67. =head1 COPYRIGHT
  68. Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
  69. Licensed under the Apache License 2.0 (the "License"). You may not use
  70. this file except in compliance with the License. You can obtain a copy
  71. in the file LICENSE in the source distribution or at
  72. L<https://www.openssl.org/source/license.html>.
  73. =cut