openssl_sign(): supplied key param cannot be coerced into a private key

September 19, 2015 § Leave a comment

Hello, just wanted to write something coming back after a long time. Please excuse my absence, life has been very busy with so much other priorities.

This post is for those who are using a PHP-DKIM solution and experiencing this below error –

openssl_sign(): supplied key param cannot be coerced into a private key

This happens when you have inputted a wrong private key input in the openssl_sign(). The third parameter is actually the “private key id” received from a call on openssl_get_privatekey(). But often its mistakenly gets passed with a string value of the private key lines.

So, here is the solution –
1) Prepare the “private key id”:
$fp = fopen("/path/to/file/.htkeyprivate", "r");
$privKey = fread($fp, 8192);
fclose($fp);
$pKeyId = openssl_get_privatekey($privKey, 'optional_passphrase');

2) Use in the openssl_sign:
openssl_sign($dataToSign, $signatureVar, $pKeyId);

If you’re using PHP-DKIM class based solution (object oriented), you may put the below code in the _construct() of the main class:

public function __construct()
{
$fp = fopen("/path/to/file/.htkeyprivate", "r");
$privKey = fread($fp, 8192);
fclose($fp);
$pKeyId = openssl_get_privatekey($privKey, 'optional_passphase');

$this->open_SSL_priv = $pKeyId;
}

Hope this helps you. I will definitely try to write again whenever I get time. Theres a lot to share from regular development experiences but time has bound me.

Happy Blogging!

Advertisements

Some helpful Firefox add-ons for web developers

December 11, 2009 § 4 Comments

I want to share some helpful Firefox add-ons that you might like. In my case, they all help me a lot in my development.

Helpful Firefox add-ons:

Firebug: Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

See more info: https://addons.mozilla.org/en-US/firefox/addon/1843

Firepicker: Simple color picker plugin for Firebug.

See more info: https://addons.mozilla.org/en-US/firefox/addon/15032

Live HTTP Headers: View HTTP headers of a page and while browsing.

See more info: https://addons.mozilla.org/en-US/firefox/addon/3829

Quick Java: Allows quick enable and disable of Java and Javascript from the status bar.

See more info: https://addons.mozilla.org/en-US/firefox/addon/1237

SEO Live YSRank: Live search rank at the status bar, top searched keywords and search volume data for a specific site. Great for search marketing, keywords research and SEO.

See more info: https://addons.mozilla.org/en-US/firefox/addon/15067

IE Tab: This is a great tool for web developers, since you can easily see how your web page displayed in IE with just one click and then switch back to Firefox.

See more info: https://addons.mozilla.org/en-US/firefox/addon/1419

Validator: This addon for Firebug will send the current HTML source to http://validator.w3.org/check and display any errors that are returned by this service.

See more info: https://addons.mozilla.org/en-US/firefox/addon/14860

View Source Chart: This add-on:
* Graphically Displays HTML Tag Boundaries
* Graphically Defines Tag Nesting Order, Structure and Hierarchy
* Adds Simple and Powerful UI *to* Source Code

See more info: https://addons.mozilla.org/en-US/firefox/addon/655

CSS Reloader: CSS Reloader is an extension that allows you to reload all the CSS of any site without you have to reload the page itself. You can use the keyboard shortcut F9, or the context-menu’s option “Reload CSS” to reload the CSS files or at page.

Very useful especially when you do pixel pushing.

See more info: https://addons.mozilla.org/en-US/firefox/addon/46211

FireFTP: FireFTP is a free, secure, cross-platform FTP client for Mozilla Firefox which provides easy and intuitive access to FTP servers.

See more info: https://addons.mozilla.org/en-US/firefox/addon/684

InfoRSS: Displays RSS, Atom, parsed HTML and NNTP feed in a scrolling area in the status bar. Compatible with podcasting RSS which can be downloaded directly. It’s also a good Google email notifier.

See more info: https://addons.mozilla.org/en-US/firefox/addon/361

Link Checker: Check the validity of links on any webpage.

See more info: https://addons.mozilla.org/en-US/firefox/addon/532

RSS Validator: Validates a page using the W3C RSS Validator.

See more info: https://addons.mozilla.org/en-US/firefox/addon/2294?src=reco

Hope this helps. I will share more in future.

Thanks.

Set your own timezone on a shared hosting

December 6, 2009 § 7 Comments

If you are a web application developer and had opportunities to work on various client servers around the globe, you may have already experienced the timezone related problems in the server script. This problem comes when the hosting is a shared one and the website runs for a different timezone than the server’s timezone. For example – I am running a website for my local community here in Dhaka/Bangladesh (timezone GMT + 7.00) but my server which is a shared one resides in the United States (say a timezone like GMT – 7). As this is a shared server, the timezone was set by the administrator to their local time. So every call to PHP date() and/or time() function will always return the server’s local time causing a mismatch with my local time in my website.

To overcome this situation, you have to change your default date time using PHP function date_default_timezone_set(your_time_zone_string). For my case, it was following:

date_default_timezone_set('Asia/Dhaka');

Add this line before executing/calling any date and/or time functions.

Below might be a quick test for you:

—————————
<?php
echo 'OLD Time: ' . date('Y-m-d H:i:s a');

date_default_timezone_set('Asia/Dhaka');

echo '<br />';

echo 'New Time: ' . date('Y-m-d H:i:s a');
?>
—————————-

That’s it.

Read more on function date_default_timezone_set: http://us3.php.net/date_default_timezone_set

See the list of supported timezones here: http://us3.php.net/manual/en/timezones.php

Happy PHPing!

Google Base Data API Error – You must specify an id for this item

March 31, 2009 § Leave a comment

For those who have recently faced this error during product uploading to Google Base, please note that you have to add an additional attribute <g:id> with each of your entries. Google has recently added more documentation on this:

http://code.google.com/apis/base/starting-out.html#products

Thanks.


Rupom

Beendobox :: Check and Send email without leaving Facebook!

May 9, 2008 § 3 Comments

Finally we were able to release an Alpha version of the Beendobox on Facebook. Now we can say there is a web application that makes life easier when accessing multiple email accounts. Currently it supports Hotmail, Yahoo & Gmail and hoping AOL & POP3 very soon.

Find it here: http://apps.facebook.com/beendobox/

Check and Send email without leaving Facebook! Beendo‘s Beendobox (Alpha) application provides one-stop access to all your email inboxes from Hotmail, Yahoo! Mail, and Google Gmail.

Beendobox on Facebook

Try it out today. Beendobox is safe and secure. Your passwords are not stored unless your choose to “remember passwords” for extra login convenience.

Add this application if you want to make your emailing life easier!

Please send feedbacks (bugs & suggestions) to us so we can work for a better release.

Thanks.


Rupom

Google App Engine needs PHP support

April 11, 2008 § Leave a comment

Google App Engine was launched but it does not support PHP. This article presents some ideas that may help Google adding PHP support sooner rather than later.

Please read the full story and digg it to let Google know our combined voice.

read more | digg story

My Facebook Applications

March 1, 2008 § Leave a comment

I am playing with FB apps. See the ones that I added since yesterday:

1. http://apps.facebook.com/phpresource/ – for phpResource Feeds

2. http://apps.facebook.com/crickets/ – for cricket updates live from cricinfo.com

3. http://apps.facebook.com/cricketbd/– for cricket updates live from cricinfo.com (Bangladesh cricket included)

Do you want to build one? Follow my previous post. It’s very easy to create one.

Thanks.


Rupom

Where Am I?

You are currently browsing the phpResource category at Rupom Here.