Skip to content

X509 #4

@wanaoishi

Description

@wanaoishi

Hi I am trying to generate a X509 cert, and I have tryied to use the method from http://phpseclib.sourceforge.net/x509/examples.html#selfsigned
But it's not working with your bundle, I have the RSA key but can't have the CERT generate.

My function is the following:
Protected function GenerateCertWCA(){
// create private key / x.509 cert for stunnel / website
$privKey = new Crypt_RSA();
$pKey = $privKey->createKey();
$privKey->loadKey($pKey['privatekey']);

    $pubKey = new Crypt_RSA();
    $pubKey->loadKey($pKey['publickey']);
    $pubKey->setPublicKey($pKey['publickey']);

    $subject = new File_X509();
    $subject->setDN(
        array(
            'rdnSequence' => array(
                array(
                    array(
                        'type' => 'id-at-organizationName',
                        'value'=> 'xxxxxxxx'
                    )
                )
            )
        )
    );

    $subject->setDomain('www.xxxxxx.org');
    // multiple domain names: $subject->setDomain('www.google.com', 'www.yahoo.com');

    $issuer = new File_X509();
    $issuer->setPrivateKey($pKey['privatekey']);
    $issuer->setDN($subject->getDN());

    $x509 = new File_X509();
    $x509->setStartDate('-1 month'); // default: now
    $x509->setEndDate('+1 year'); // default: +1 year

    $result = $x509->sign($issuer, $subject);
    $value = $privKey->getPrivateKey();
    $value = $value . "\r\n";
    $value = $value . $x509->saveX509($result);
    $value = $value . "\r\n";
    return $value;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions