-1

I'm writing a PHP extension and wanted to call openssl extension functions from my extension, to be specific, I want to call openssl_x509_read function from inside my extension. Is it possible? And how do I do it?

1

1 Answer 1

0

Found the answear, here's how to call the function openssl_x509_read from your module:

#define FUNC_OPENSSL_X509_READ          "openssl_x509_read"

zval *openssl_x509_read(unsigned char *certificate_data, int certificate_data_length) {
    zval *function_name, *certificate, *param_certificate, **params[1];

    TSRMLS_FETCH();

    MAKE_STD_ZVAL(function_name);
    ZVAL_STRINGL(function_name, FUNC_OPENSSL_X509_READ,
            strlen(FUNC_OPENSSL_X509_READ), 0);

    MAKE_STD_ZVAL(param_certificate);
    ZVAL_STRINGL(param_certificate, certificate_data, certificate_data_length,
            0);
    params[0] = &param_certificate;

    if (call_user_function_ex(CG(function_table), NULL, function_name,
            &certificate, 1, params, 0, NULL TSRMLS_CC) != SUCCESS) {
        zend_error(E_ERROR, "Function openssl_x509_read failed");

        return NULL;
    }

    FREE_ZVAL(function_name);
    FREE_ZVAL(param_certificate);

    return certificate;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.