<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.openssl-csr-get-public-key" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>openssl_csr_get_public_key</refname>
  <refpurpose>Returns the public key of a <acronym>CSR</acronym></refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type class="union"><type>OpenSSLAsymmetricKey</type><type>false</type></type><methodname>openssl_csr_get_public_key</methodname>
   <methodparam><type class="union"><type>OpenSSLCertificateSigningRequest</type><type>string</type></type><parameter>csr</parameter></methodparam>
   <methodparam choice="opt"><type>bool</type><parameter>short_names</parameter><initializer>&true;</initializer></methodparam>
  </methodsynopsis>
  <para>
   <function>openssl_csr_get_public_key</function> extracts the public key 
   from <parameter>csr</parameter> and prepares it for use by other functions.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
     &openssl.param.csr;
    <varlistentry>
     <term><parameter>short_names</parameter></term>
     <listitem>
      <warning>
       <para>
        This parameter is ignored
       </para>
      </warning>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns an <classname>OpenSSLAsymmetricKey</classname> on success, or &false; on error.
  </para>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <informaltable>
   <tgroup cols="2">
    <thead>
     <row>
      <entry>&Version;</entry>
      <entry>&Description;</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry>8.0.0</entry>
      <entry>
       On success, this function returns an <classname>OpenSSLAsymmetricKey</classname> instance now;
       previously, a &resource; of type <literal>OpenSSL key</literal> was returned.
      </entry>
     </row>
     <row>
      <entry>8.0.0</entry>
      <entry>
       <parameter>csr</parameter> accepts an <classname>OpenSSLCertificateSigningRequest</classname> instance now;
       previously, a &resource; of type <literal>OpenSSL X.509 CSR</literal> was accepted.
      </entry>
     </row>
    </tbody>
   </tgroup>
  </informaltable>
 </refsect1>
 
 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>openssl_csr_get_public_key() example</title>
    <programlisting role="php">
<![CDATA[
<?php
$subject = array(
    "commonName" => "example.com",
);
$private_key = openssl_pkey_new(array(
    "private_key_bits" => 2048,
    "private_key_type" => OPENSSL_KEYTYPE_RSA,
));
$csr = openssl_csr_new($subject, $private_key, array('digest_alg' => 'sha256') );
$public_key = openssl_csr_get_public_key($csr);
$info = openssl_pkey_get_details($public_key);
echo $info['key'];
?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>openssl_csr_get_subject</function></member>
    <member><function>openssl_csr_new</function></member>
    <member><function>openssl_pkey_get_details</function></member>
    <member><function>openssl_pkey_export_to_file</function></member>
    <member><function>openssl_pkey_export</function></member>
   
   </simplelist>
  </para>
 </refsect1>
 
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
