ssl and php (generate certs)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • xer

    ssl and php (generate certs)

    I want to generate ssl certificate (with public key) and private key. My
    code:

    $ssl_configargs = array(
    "digest_alg " => "sha1",
    "private_key_bi ts" => 2048,
    "private_key_ty pe" => OPENSSL_KEYTYPE _RSA,
    "encrypt_ke y" => false
    );
    $dn = array("countryN ame" => $_POST[ 'country' ],
    "stateOrProvinc eName" => $_POST[ 'state' ],
    "localityNa me" => $_POST[ 'city' ],
    "organizationNa me" => $_POST[ 'org' ],
    "organizational UnitName" => $_POST[ 'unit' ],
    "commonName " => $_POST[ 'name' ],
    "emailAddre ss" => $_POST[ 'mail' ] );

    $numberofdays = $_POST[ 'days' ];

    $pkey = openssl_pkey_ne w( $ssl_configargs );
    // there is a error
    $csr = openssl_csr_new ( $dn, $privkey, $ssl_configargs );
    $sscert = openssl_csr_sig n( $csr, null, $privkey, $numberofdays );

    openssl_csr_exp ort( $csr, $csrout );
    openssl_x509_ex port( $sscert, $certout );
    openssl_pkey_ex port( $privkey, $pkeyout, $configargs[
    'licence_pwd' ] );

    I've tried use openssl_pkey_ne w without param ($ssl_configarg s ), but it
    still doesn't work.
    My errors:

    Warning: openssl_csr_sig n(): key type not supported in this PHP build! in
    xx.php on line xx

    Warning: openssl_csr_sig n(): failed to sign it in xx.php on line x

    Warning: openssl_x509_ex port() expects parameter 1 to be resource, boolean
    given in xx.php on line xx

    Warning: openssl_pkey_ex port(): key type not supported in this PHP build! in
    xx.php on line xx

    Can somebody help me? This is very important. Thx



  • Drakazz

    #2
    Re: ssl and php (generate certs)

    Seems like your OPENSSL_KEYTYPE _RSA would be undefined, get the value
    out of somewhere, like a readme or look in the source code. it is
    usually an integer. Anyway, the problem might be that your php version
    is incompatible with the library etc..

    If it also doesnt work with the params, ask the developers who built
    the program or whomever it is made/supported by.

    Comment

    Working...