| | |
Need Help On SSL
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
You just need a ssl enabled on your web server and a ssl certificate.
Then the client just uses https:// instead of http://
Any POST data will be encrypted.
Then the client just uses https:// instead of http://
Any POST data will be encrypted.
Well we can't help if you don't post the code and tell us *exactly* what the error message is or what the undesired/desired behaviour is. You just say you want to encrypt some text but where is this text? in a web form? what? are you using HTTP or Opening TCP sockets? More info please.
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Solved Threads: 0
The text I want to encrypt will be available in a variable somehow.
It actually returns an error saying the browser speaks plain html it couldn't understood by the server
But when I made my code to as shown below I got the following result
**************
<?php
$fp=fopen("/usr/local/apache/conf/ssl.crt/server.crt","r");
$pub_key=fread($fp,8192);
fclose($fp);
openssl_get_publickey($pub_key);
//print_r($pub_key);
$strMessage='This';
$strAddress="localhost";
$intPort="443";
$strScriptName = "index.php";
$fphSocket = fsockopen ("ssl://".$strAddress, $intPort, $strErrorNumber, $strErrorString,30);
//stream_set_blocking ( $fphSocket, 0 );
if (!$fphSocket) {
echo"Outer". "$strErrorString ($strErrorNumber)<br />\n";
}
else{
$strContent="Message=".$strMessage;
openssl_public_encrypt($strContent,$encrypted,$pub_key);
$intContentLength = strlen($strContent);
$strOutput = "POST /index.php HTTP/1.0\r\n";
$strOutput .= "Content-Length: $intContentLength\r\n\r\n";
$strOutput .= $encrypted;
fwrite($fphSocket, $strOutput);
$sta=socket_get_status($fphSocket);
while (!feof($fphSocket)) {
$strResponse .= fgets($fphSocket, 128);
}
fclose($fphSocket);
print_r($strResponse);
}
?>
**************
HTTP/1.1 200 OK
Date: Wed, 26 Sep 2007 05:04:35 GMT
Server: Apache/1.3.34 (Unix) PHP/5.2.0 mod_ssl/2.8.25 OpenSSL/0.9.8b
X-Powered-By: PHP/5.2.0
Connection: close
Content-Type: text/html
Thank You
It actually returns an error saying the browser speaks plain html it couldn't understood by the server
But when I made my code to as shown below I got the following result
**************
<?php
$fp=fopen("/usr/local/apache/conf/ssl.crt/server.crt","r");
$pub_key=fread($fp,8192);
fclose($fp);
openssl_get_publickey($pub_key);
//print_r($pub_key);
$strMessage='This';
$strAddress="localhost";
$intPort="443";
$strScriptName = "index.php";
$fphSocket = fsockopen ("ssl://".$strAddress, $intPort, $strErrorNumber, $strErrorString,30);
//stream_set_blocking ( $fphSocket, 0 );
if (!$fphSocket) {
echo"Outer". "$strErrorString ($strErrorNumber)<br />\n";
}
else{
$strContent="Message=".$strMessage;
openssl_public_encrypt($strContent,$encrypted,$pub_key);
$intContentLength = strlen($strContent);
$strOutput = "POST /index.php HTTP/1.0\r\n";
$strOutput .= "Content-Length: $intContentLength\r\n\r\n";
$strOutput .= $encrypted;
fwrite($fphSocket, $strOutput);
$sta=socket_get_status($fphSocket);
while (!feof($fphSocket)) {
$strResponse .= fgets($fphSocket, 128);
}
fclose($fphSocket);
print_r($strResponse);
}
?>
**************
HTTP/1.1 200 OK
Date: Wed, 26 Sep 2007 05:04:35 GMT
Server: Apache/1.3.34 (Unix) PHP/5.2.0 mod_ssl/2.8.25 OpenSSL/0.9.8b
X-Powered-By: PHP/5.2.0
Connection: close
Content-Type: text/html
Thank You
![]() |
Similar Threads
- Fread + Ssl (PHP)
- In Need of an SSL (eCommerce)
- Ssl Outlook Problem (Windows NT / 2000 / XP)
- Netgear WGR614 v4 problem with SSL sites... (Networking Hardware Configuration)
- msn messenger not working.. SSL (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: php included header file wont input code when on the server
- Next Thread: select information from databse
| Thread Tools | Search this Thread |
# .htaccess 5.2.10 access alexa apache api array beginner broken cakephp checkbox class clean clients cms code convert cron curl database date directory display dissertation dropdown dynamic echo$_get[x]changingitintovariable... email encode error fairness file folder form forms function functions google hack href htaccess html htmlspecialchars image include indentedsubcategory ip javascript joomla legislation limit link local login mail memberships menu methods multiple multipletables mysql mysqlquery network newsletters oop open passwords paypal pdf persist php provider query radio random redirect remote script search secure server sessions simple sockets source space spam sql system table tutorial upload url user variable video voteup web youtube






