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