1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-->
<refentry id="fn_xenc_x509_from_csr">
<refmeta>
<refentrytitle>xenc_x509_from_csr</refentrytitle>
<refmiscinfo>hash</refmiscinfo>
</refmeta>
<refnamediv>
<refname>xenc_x509_from_csr</refname>
<refpurpose>Generate x509 certificate from CSR.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_xenc_x509_from_csr">
<funcprototype id="fproto_xenc_x509_from_csr">
<funcdef>varchar <function>xenc_x509_from_csr</function></funcdef>
<paramdef>in <parameter>ca_key_name</parameter> varchar</paramdef>
<paramdef>in <parameter>cli_key_name</parameter> varchar</paramdef>
<paramdef>in <parameter>csr_str</parameter> varchar</paramdef>
<paramdef>in <parameter>serial_no</parameter> varchar</paramdef>
<paramdef>in <parameter>days_validity</parameter> varchar</paramdef>
<paramdef>in <parameter>hours_validity</parameter> varchar</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_xenc_x509_from_csr"><title>Description</title>
<para>This function generates Certificate Signing Request (CSR). The function return 1 upon success,
sql error on failure. The new certificate can be exported in PEM format with
<link linkend="fn_xenc_pem_export"><function>xenc_pem_export(cli_key_name)</function></link>.</para>
</refsect1>
<refsect1 id="params_xenc_x509_from_csr"><title>Parameters</title>
<refsect2>
<title>ca_key_name</title>
<para>The name of CA private key which will be used to sign certificate.</para>
</refsect2>
<refsect2>
<title>cli_key_name</title>
<para>The name of a key which will be created and will contains the client certificate.</para>
</refsect2>
<refsect2>
<title>csr_str</title>
<para>pem encoded CSR.</para>
</refsect2>
<refsect2>
<title>serial_no</title>
<para>Serial number.</para>
</refsect2>
<refsect2>
<title>days_validity</title>
<para>How many days will be valid the certificate.</para>
</refsect2>
<refsect2>
<title>hours_validity</title>
<para>How many hours will be valid the certificate.</para>
</refsect2>
</refsect1>
<refsect1 id="ret_xenc_x509_from_csr"><title>Return Types</title>
<para>the function returns 1 upon success, sql error on failure.</para>
</refsect1>
<refsect1 id="errors_xenc_x509_from_csr"><title>Errors</title>
<table><title>Errors signalled by <function>xenc_x509_from_csr</function></title>
<tgroup cols="4">
<thead>
<row>
<entry>SQLState</entry>
<entry>Error Code</entry>
<entry>Error Text</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><errorcode>22023</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>The key [name of the key] already exists</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>22023</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>Missing or invalid signer certificate</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>22023</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>Invalid certificate request</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>22023</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>Invalid certificate request public key</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>22023</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>Signature did not match the certificate request</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>22023</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>Invalid certificate request subject name</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>42000</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>Can not create x.509 structure</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>42000</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>Can not sign certificate</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>42000</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>The type of public key is not supported mus tbe RSA or DSA</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>42000</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>Can not create a key</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>42000</errorcode></entry>
<entry><errorcode>XECXX</errorcode></entry>
<entry><errorname>Can not sign certificate : [the sign error text]</errorname></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</refsect1>
<refsect1 id="examples_xenc_x509_from_csr"><title>Example</title>
<example id="ex_xenc_x509_from_csr">
<para>The following example demonstrates how to generate Certificate Signing Request (CSR).</para>
<itemizedlist mark="bullet">
<listitem><link linkend="vfoafsslcacondt">Using Conductor, for user dba import a certificate with primary key and with name id_rsa.</link></listitem>
<listitem>Execute:</listitem>
</itemizedlist>
<programlisting><![CDATA[
SQL>create procedure csr_demo()
{
declare kname, cvalue varchar;
declare _key any;
declare _output int;
xenc_key_RSA_create ('RSAKey1', 1024);
_key := xenc_x509_csr_generate ('RSAKey1',
vector (
'CN', 'Demo user',
'C', 'US',
'O', 'OpenLink',
'OU', 'Accounts',
'emailAddress', 'demo@openlinksw.com'),
vector ('subjectAltName', 'URI: http://www.openlinksw.com/dataspace/person/demo#this', 'nsComment', 'Virtuoso Generated Certificate',
'authorityKeyIdentifier', 'keyid,issuer:always'));
xenc_x509_from_csr ('id_rsa', 'MyKey1', _key , sequence_next ('ca_id_rsa'), 365, 100);
return xenc_pem_export ('MyKey1');
}
;
Done. -- 0 msec.
SQL> select csr_demo();
temp2
VARCHAR
_______________________________________________________________________________
-----BEGIN CERTIFICATE-----
MIIDSjCCAjKgAwIBAgIBEzANBgkqhkiG9w0BAQQFADBVMQswCQYDVQQIEwJvbDEL
MAkGA1UEChMCb2wxCzAJBgNVBAsTAm9sMQ0wCwYDVQQDEwRqb2huMR0wGwYJKoZI
hvcNAQkBFg5qb2huQGdtYWlsLmNvbTAeFw0xMTA2MDcxNTAxNDhaFw0xMjA2MTAx
OTAxNDhaMGsxEjAQBgNVBAMTCURlbW8gdXNlcjELMAkGA1UEBhMCVVMxETAPBgNV
BAoTCE9wZW5MaW5rMREwDwYDVQQLEwhBY2NvdW50czEiMCAGCSqGSIb3DQEJARYT
ZGVtb0BvcGVubGlua3N3LmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
3Ma/MlMrGruwpDsW2D3iYA6sqFqldPsgx837dNJel8ZQu5/0Nyr5DCtAQNq6nWZo
0bezK9UIfAXEQXWt4S7IMPfTF6oCT85YDsQEEE/o1spsZ9Q7kXhKu3R3LNNiTxYr
TR4FSl361pUqyYngSMTxVWJxKnPW30p94i5QuQjLF1sCAwEAAaOBkjCBjzAdBgNV
HQ4EFgQUF5wTSXH98IqiaaxfVTNcui8p8SowPwYDVR0RBDgwNoY0aHR0cDovL3d3
dy5vcGVubGlua3N3LmNvbS9kYXRhc3BhY2UvcGVyc29uL2RlbW8jdGhpczAtBglg
hkgBhvhCAQ0EIBYeVmlydHVvc28gR2VuZXJhdGVkIENlcnRpZmljYXRlMA0GCSqG
SIb3DQEBBAUAA4IBAQCwSN3y6yeCNe+/izo5GwM+16cjmZkyMUYmAO62I6T62jmI
p0nYaVhJ9WV0ntVnx1H8/LKwrgyLlhXacVw4jyXwFMSo+YuONj+kKpobNH2cl+u1
+c0kJGbY/eS99S2D3JhL6n+QukvQIqhYniZ21wT1ugwpN2A7NtY+g925+vQBO0UH
0wQm3eQk8NADEjcqrmGmJcrK22jfaBNov+O2wvcZQM7WIKm98f/7So7kBN0BoRX8
7LRf3zIhp4f9fk1QDwlm9NgwgxARqNOfRuJU2YU1ICz88LbwM4XDeb+Mdr0YMNdU
6eYkCB4vKsVH+s1E8m67QZ8TGxpNZLYXLZZBdt86
-----END CERTIFICATE-----
1 Rows. -- 172 msec.
]]></programlisting>
</example>
</refsect1>
<refsect1 id="seealso_xenc_x509_from_csr"><title>See Also</title>
<para><link linkend="fn_get_certificate_info">get_certificate_info()</link></para>
<para><link linkend="fn_xenc_x509_csr_generate">xenc_x509_csr_generate()</link></para>
<para><link linkend="fn_xenc_x509_generate">xenc_x509_generate()</link></para>
</refsect1>
</refentry>
|