Wednesday, April 30, 2014

ldap_bind(): Unable to bind to server: Protocol error
You have to specify the protocol version prior before making a call to ldap_bind(), when the server is expecting LDAP protocol version 3. else you will receive the above error

In order to avoid this, make this call:

<?php
ldap_set_option($ldapConnResult, LDAP_OPT_PROTOCOL_VERSION, 3);
?>

Where $ldapConnResult  is the result returned by ldap_connect() function.

Call to undefined function ldap_connect()

Call to undefined function ldap_connect()
Just go to php.ini file and un-comment php_ldap extension line

Thursday, April 24, 2014

PEM routines:PEM_read_bio:no start line

PEM routines:PEM_read_bio:no start line
 I got this error when I tried to convert a private key to PKCS12 format using openssl_pkcs12_export() function under PHP, after 48 hours of trying many solutions I finally found the wright one, it's soo simple just change the format of the private key (PEM encoded) from

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,25E7BB5EB27D828C

<--- Private key here ----->
-----END RSA PRIVATE KEY-----

to

-----BEGIN RSA PRIVATE KEY-----
<--- Private key here ----->
-----END RSA PRIVATE KEY-----
 
That's all !

I reported this error to PHP and it's published on function manual http://www.php.net/manual/en/function.openssl-pkcs12-export.php#114908

Wednesday, April 23, 2014

error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt error:0906A065:PEM routines:PEM_do_header:bad decrypt
I got this error while working with OpenSSL library  on PHP, this happen when you try to export the private key of a certificate using bad passphrase, just make sure taht you are using the wright one.

Thursday, March 13, 2014

Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0
  The web server can't load an external php file, to patch it, go to php.ini file, find allow_url_include=off  and set it to on, restart all apache services and it's done !

Note: it's insecure to allow external files to be included in your web page (see why) so use it on your own risk.

Monday, March 10, 2014

RSA operation error
5747:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size:rsa_pk1.c:151:
Basically RSA is not aimed to encrypt large data file, so you will get this error when you try to encrypt a file such as length(file) > length(RSA key).
I suggest to calculate first hash version of the file using MD5 or SHA-1 then encrypt it using the key.

Note: in real cryptographic system, RSA public/private key are only used to exchange symmetric key.

Friday, March 7, 2014

How to Fix: Ubanble to establish VPN

it was strange for me at first time to get this error , first thing that I did in order to solve it is to check that the VPN server is reachable using Ping command and the firewall is configured to let VPN access ... I found everything working well, so after deep searching I found that Internet Connection Sharing  (ICS) service is the responsible of that, I turned  it off and the VPN tunnel is re-established. 

NB: is not recommended to turn off ICS service permanently