English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
OpenSSL is a free open-source module designed to handle communication over computer networks. OpenSSL is a tool used for Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols.
Websites use the Secure Sockets Layer (SSL) to secure data transmission between two computers. SSL certificates are responsible for encrypting data between two computers. The two computers involved can be the data sharing between a client and a server. When you share data such as passwords, credit card details, home address, social security numbers, etc., it must be protected, and SSL certificates will protect it. SSL certificates ensure the authentication of the identity of the two computers involved to ensure a secure connection.
By default, the OpenSSL module has been added to PHP. You can remove it by deleting it in php.ini.; extension = php_openssl.dllStartUse the semicolon (;) to enable them. After that, restart Apache and confirm that the changes have taken effect, then save the following code as .php and execute .php in the browser.
<?php phpinfo(); ?>Test to see‹/›
You should see OpenSSL enabled in your browser as follows:
openssl.cnf is the configuration file that contains all the default configurations required for OpenSSL to work properly. To execute OpenSSL, the first thing php will try to find is the configuration file. To get the same file, you must add the Php folder to the environment variable.
If you are a Windows user, please follow the steps below to set the environment variable for the Php folder:
1.Right-click on My Computer and go to Properties.
2.Go to Advanced System Settings.
3.Click the 'Environment Variables' button.
4.Edit the path variable and then click the 'Edit' button.
5.Now add the Php folder path at the end. I am using XAMPP, and my Php folder is c:\xampp\php;
6.After completion, click the OK button.
7.Now open the Command Prompt and enter the command: openssl version -a.
C:\Windows\system32>openssl version -a OpenSSL 1.0.2l 25 May 2017 built on: reproducible build, date unspecified platform: mingw64 options: bn(64,64) rc4(16x,int) des(idx,cisc,2,long) idea(int) blowfish(idx) compiler: x86_64-w64-mingw32-gcc -I. -I.. -I../include -D_WINDLL -DOPENSSL_PIC -DOPENSSL_THREADS -D_MT -DDSO_WIN32 -static-libgcc -DL_ENDIAN -O3 -Wall -DWIN32_ LEAN_AND_MEAN -DUNICODE -D_UNICODE -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DO PENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSH A512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM OPENSSLDIR: "/etc/ssl"
Now, php will be able to find the openssl.cnf configuration file.
The following table lists all functions related to PHP OpenSSL. Here, 'version' indicates the earliest version of PHP that supports the function feature.
Number | Function | Description | Version |
---|---|---|---|
1 | openssl_pkey_new() | Return the resource identifier with a new private and public key pair | 5.0.0 |
2 | openssl_pkey_get_private() | Return the private key | 5.0.0 |
3 | openssl_pkey_get_public() | Return the public key | 5.0.0 |
4 | openssl_pkey_export_to_file() | Export the key to a file | 5.0.0 |
5 | openssl_private_encrypt() | Encrypt data with private key | 5.0.0 |
6 | openssl_public_encrypt() | Encrypt data with public key | 5.0.0 |
7 | openssl_public_decrypt() | Decrypt data with public key | 5.0.0 |
8 | openssl_private_decrypt() | Decrypt data with private key | 5.0.0 |