SSL error: Unable to get private key from

Posted by Michael Roth on Februar 02, 2015
Allgemein / 2 Comments

OpenSSL recently changed the default behaviour for key generation. The command openssl req -newkey rsa:2048 used to generate RSA keys in the PKCS #1 format. In these format the key starts with -----BEGIN RSA PRIVATE KEY-----.

The new behaviour is to generate RSA keys in the  PKCS #8 format. Now the key file starts with -----BEGIN PRIVATE KEY-----.

If you try to load the new key format into MySQL you will get the error:

SSL error: Unable to get private key from

Adding RSA into the key preamble removes the error message but does not solves the problem nor change the key format. This will lead to the error:

ERROR 2026 (HY000): SSL connection error: protocol version mismatch

To get the key working with MySQL it is necessary to convert the format. This can be done with:

openssl rsa -in key.pem -out key.pem

[UPDATE] If the key is in the correct format and the error persists check the file permissions. The key must be readable by the mysql user, usually mysql. The simpest way is the change the ownership to mysql:mysql.

[1] http://askubuntu.com/questions/194074/enabling-ssl-in-mysql

Multi-Domain Projects on AWS Elastic Beanstalk

Posted by Michael Roth on Januar 26, 2013
Cloud, Linux / 2 Comments

Using Elastic Beanstalk from  Amazon Web Services is a create way to deploy large projects and be ready for a gain in visitors. Because I have a few projects which are too small to deploy each project as its own Elastic Beanstalk  application I looked for a way to deploy several projects with multiple Domains into one AWS EB application.

In the past the only way to configure application environments was to use customized AMIs. This would mean that I can not update my application to newer Amazon AMIs. So I would have to update my AMI regularly on my own.

A new and better way is to use the new configuration files. After deploying an application the configuration files, stored in the folder .ebextensions on the root directory of the applichation, are processed. All configuration files must end with ‚.config‘.

The Elastic Beanstalk uses regular EC2 instances with an apache webserver. So I used the configuration files to create an file inside the apache folder to tell the webserver how to handle multiple domains. The deployed PHP application is stored inside the /var/www/html folder.

Here is the configuration file. I saved it under .ebextensions/vhost.config

files:
  "/etc/httpd/conf.d/vhost.conf":
    mode: "000644"
    owner: root
    group: root
    encoding: plain
    content: |
      NameVirtualHost *:80

      <VirtualHost *:80>
        ServerName www.projekt1.de
        ServerAlias projekt1.de
        DocumentRoot /var/www/html/projekt1/
      </VirtualHost>
      <VirtualHost *:80>
        ServerName static.projekt1.de
        DocumentRoot /var/www/html/static/
      </VirtualHost>

The lines after the content entry were copied into a new file /etc/httpd/conf.d/vhost.conf. The webserver reads this file on startup an creates new vhosts with different root folders. All requests for www.projekt1.de or projekt1.de use /var/www/html/projekt1/ als document root. Requests to static.projekt1.de use folder static inside the application as document root.

For detailed information on how to configure multiple domains in apache read the VirtualHost Examples from the apache project page.

If you have any questions, problems or suggestions please write a comment on this post.

AssociateTag in Zendframework Amazon Anfragen

Posted by Michael Roth on Januar 06, 2012
PHP / Kommentare deaktiviert für AssociateTag in Zendframework Amazon Anfragen

Wie bereits erwähnt hat Amazon die Product Advertising API geändert. Daher ist nun bei jeder Anfrage eine PartnerId (engl. AssociateTag) notwendig, sonst wird folgende Fehlermeldung ausgegeben:

Your request is missing required parameters.
Required parameters include AssociateTag.

Es gibt zwei Möglichkeit dieses AssociateTag im Zendframework zu setzen. Die PartnerID  kann an die beiden Anfrage itemLookup() und itemSearch() im Optionen-Array mit übergeben werden.

$aws = new RD_Amazon_Query($awsID,'DE',$awsKey);
$item=$aws->category('All')->itemLookup($asin,
                                    array('ResponseGroup' => 'OfferFull, BrowseNodes,Large',
                                          'MerchantId' => 'Amazon',
                                          'AssociateTag' => 'rothdigital-21');

Als Alternative kann die Methode AssociateTag(‚rothdigital-21‘)  benutzt werden um den Wert als Methodenaufruf zu setzten. Wichtig ist, dass die Category bei Anfragen als erstes gesetzt wird und dann erst AssociateTag.

$aws = new RD_Amazon_Query($awsID,'DE',$awsKey);
$item=$aws->category('All')->AssociateTag('rothdigital-21')
                           ->itemLookup($asin,
                                    array('ResponseGroup' => 'OfferFull, BrowseNodes,Large',
                                          'MerchantId' => 'Amazon');

Diese beiden Wege funktionieren mit Zendframework 1.11. Es gibt schon einen Bug-Report, der vorschlägt die PartnerId in den Konstruktor zu übernehmen. Daher kann sich das Verhalten im nächsten Release des Zendframework wieder ändern. Sollten Sie Änderungen feststellen, benutzen Sie einfach hier die Kommentarfunktion.

Tags: , ,

phplist und Amazon Simple Email Service

Posted by Michael Roth on November 04, 2011
Cloud, Internet / Kommentare deaktiviert für phplist und Amazon Simple Email Service

phplist ist ein browserbasiertes Programm, das es erlaubt Newsletter an eine große Anzahl von Empfängern zu senden. Es können Templates angelegt werden und so das Aussehen der E-Mail individuell angepasst werden. Falls ein Server auf einmal viele E-Mails sendet kann dies von einigen Mailservern als Spamversand interpretiert werden und der Newslettersender kann auf einer Blacklist landen. Um dies zu verhindern kann man mit phplist die E-Mails zeitlich versetzt senden und beispielsweise mit einem Cronjob so alle fünf Minuten 100 E-Mails senden.

Diese Methode ist aber sehr zeitaufwendig. Bei vielen Empfänger kann sich der E-Mailversand über mehrere Stunden oder Tage hinziehen. Eine Alternative ist der Amazon Simple Email Service. Dieser Dienst ermöglicht das einfache und schnelle Versenden von vielen E-Mails. Amazon hat die eignen Mailserver auf mehreren Whitelisten eingetragen und überwacht die Qualität der E-Mails, daher können diese Server nicht so einfach auf Blacklists landen.

phplist unterstützt die Verbindung zu Amazon SES leider erst in der Entwicklungsversion 2.11.6. Um Amazon SES zu nutzen sind folgende Änderungen in der Datei config/config.php notwendig:

define('PHPMAILER',0);
define('AWS_ACCESSKEYID','Your Access Key ID');
define('AWS_SECRETKEY','Your corresponding secret key');
define('AWS_POSTURL','https://email.us-east-1.amazonaws.com/');

Eine genaue Anleitung ist unter http://www.phplist.com/?lid=515 zu finden.

Tags: ,