PHP - Openssl Extension Doubt
Hello guys, i need to create a code for making connections with SSL servers (particularly SMTPS and POP3S) and i know about the existence of OpenSSL extension.
However, i'm in doubt about a basic issue: 1. Is this extension useful for creating SSL clients or SSL servers? I'm not a SSL expert, so maybe i'm misunderstanding something; i hope you can help me. Kind regards. Similar TutorialsCode: [Select] <?php // Fill in data for the distinguished name to be used in the cert // You must change the values of these keys to match your name and // company, or more precisely, the name and company of the person/site // that you are generating the certificate for. // For SSL certificates, the commonName is usually the domain name of // that will be using the certificate, but for S/MIME certificates, // the commonName will be the name of the individual who will use the // certificate. $dn = array( "countryName" => "UK", "stateOrProvinceName" => "Somerset", "localityName" => "Glastonbury", "organizationName" => "The Brain Room Limited", "organizationalUnitName" => "PHP Documentation Team", "commonName" => "Wez Furlong", "emailAddress" => "wez@example.com" ); // Generate a new private (and public) key pair $privkey = openssl_pkey_new(); // Generate a certificate signing request $csr = openssl_csr_new($dn, $privkey); // You will usually want to create a self-signed certificate at this // point until your CA fulfills your request. // This creates a self-signed cert that is valid for 365 days $sscert = openssl_csr_sign($csr, null, $privkey, 365); // Now you will want to preserve your private key, CSR and self-signed // cert so that they can be installed into your web server, mail server // or mail client (depending on the intended use of the certificate). // This example shows how to get those things into variables, but you // can also store them directly into files. // Typically, you will send the CSR on to your CA who will then issue // you with the "real" certificate. openssl_csr_export($csr, $csrout) and var_dump($csrout); openssl_x509_export($sscert, $certout) and var_dump($certout); openssl_pkey_export($privkey, $pkeyout, "mypassword") and var_dump($pkeyout); ?> Openssl is a php ext which can be enabled in a php build. If I enable this ext in my application on my own computer will it generate an ssl certificate or only speak to a certificate. Facebook suddenly requires SSL HTTPS secure canvas after 6 yrs of working with the interface all my apps are down can someone pls tell me what is going on!! I would like to know how to incorporate or use the OpenSSL in my forms, particulary in logging in. Hi, Im trying to convert a cert on the server its a .p12 file to a .pem. i first tried doing system(); commands but that never worked so i dont know what i can do now, i looked at some of the openssl php code but i cant find something that will do it, that or im doing it wrong.. heres what i was wanting to do; Code: [Select] system('openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12 -passin pass:'); system('openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12 -passout pass:1234 -passin pass:'); system('openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem -passin pass:1234'); system('cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem'); this works on my mac, but i dont know how to do it online. thanks for reading hope someone can help. Hi I develop a system using OPenSSL for Rijndael-256 (RSA-256) encryption. It works weel on an Apache server with PHP 5.3.2 on Windows and on a Linux server. But, on a Mac, I experience a weird problem. When I send a block to be decrypted, it works some times, and, without any reason, it stops and stays blocked for a while. And suddenly, it works again. When it crashes, I have the error message : Code: [Select] Wrong request for connection error:0906D06C:PEM routines:PEM_read_bio:no start line I searched on Google and couldn't really find any solution. I read it seemed to be related to the keys format. The public key used for encryption is like : Code: [Select] -----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY----- And the private is like : Code: [Select] -----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY----- Has anybody met that problem before and/or know where it comes from and how to fix it ? Thanks Hi i have php script which i have been running on on my web server which is dreamhost which is working fine... but here's the twist i have just set-up a xampp server apache 2.2 on my windows 7 machine my website is running fine expect for the openssl encrypt script which is filing to encrypt here's a sample of my code. $MY_KEY_FILE = "c:\\xampp\\apache\\bin\\my-prvkey.pem"; # public certificate file to use $MY_CERT_FILE = "c:\\xampp\\apache\\bin\\my-pubcert.pem"; # Paypal's public certificate $PAYPAL_CERT_FILE = "c:\\xampp\\apache\\bin\\paypal_cert_pem.txt"; # path to the openssl binary $OPENSSL = "c:\\xampp\\apache\\bin\\openssl.exe"; $form = array('cmd' => '_xclick', 'business' => 'removed business name for security ', 'cert_id' => 'removed cert id for security', 'lc' => 'AU', 'custom' => ''.$id.'', 'invoice' => removed business name for security', 'currency_code' => 'AUD', 'no_shipping' => '1', 'item_name' => 'removed business name for security', 'item_number' => '1', 'amount' => $total ); $encrypted = paypal_encrypt($form); function paypal_encrypt($hash) { //Sample PayPal Button Encryption: Copyright 2006-2010 StellarWebSolutions.com //Not for resale - license agreement at //http://www.stellarwebsolutions.com/en/eula.php global $MY_KEY_FILE; global $MY_CERT_FILE; global $PAYPAL_CERT_FILE; global $OPENSSL; if (!file_exists($MY_KEY_FILE)) { echo "ERROR: MY_KEY_FILE $MY_KEY_FILE not found\n"; } if (!file_exists($MY_CERT_FILE)) { echo "ERROR: MY_CERT_FILE $MY_CERT_FILE not found\n"; } if (!file_exists($PAYPAL_CERT_FILE)) { echo "ERROR: PAYPAL_CERT_FILE $PAYPAL_CERT_FILE not found\n"; } //Assign Build Notation for PayPal Support $hash['bn']= 'StellarWebSolutions.PHP_EWP2'; $data = ""; foreach ($hash as $key => $value) { if ($value != "") { //echo "Adding to blob: $key=$value\n"; $data .= "$key=$value\n"; } } // here's where i believe the problem is when creating and signing the my_cert_file i had to specify where the openssl.cnf file was do i need to do same here.. -config c:\\xampp\\apache\\bin\\openssl.cnf $openssl_cmd = "($OPENSSL smime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE " . "-outform der -nodetach -binary <<_EOF_\n$data\n_EOF_\n) | " . "$OPENSSL smime -encrypt -des3 -binary -outform pem $PAYPAL_CERT_FILE"; exec($openssl_cmd, $output, $error); if (!$error) { return implode("\n",$output); } else { return "ERROR: encryption failed"; } echo $output; }; Hi, I'm setting up a website with a custom built shopping basket which I want to link in with Paypal. I have it all done except I'm having trouble getting the button encryption working using OpenSSL. I have all the certificates done and uploaded to Paypal but when I use this function; Code: [Select] $myPublicKey = openssl_pkey_get_public("requires/paypal/my-pubcert.pem"); openssl_public_encrypt($data, $crypttext, $myPublicKey); It produces this error; Quote openssl_public_encrypt(): key parameter is not a valid public key Now I originally did my own research to try to solve this problem but have been unable to do so which is why I'm hear, My findings indicated towards the openssl.cnf which could well be the issue as I haven't indicated in any code the location of the file, but I don't know how or where I do that. Any help with this is appreciated. Scarz I am trying to use SSH2 functions in PHP and I read the documentation for each LIBSSH2, OpenSSL and PECL SSH2 and I can't figure out how to install any of them on the Windows Server X64 box. Does anyone know how to do this? http://www.php.net/manual/en/ssh2.requirements.php http://pecl.php.net/package/ssh2 http://www.openssl.org/ http://www.libssh2.org/ Thanks, sanchez I have an ecommerce site on shared hosting enviroment. My ecommerce site stores customer data (name, address, email, phone, and item purchase) in mySQL database. (No super private data like credit card numbers or social security numbers.) Using openssl (openssl_cipher, iv, etc.), I've been encrypting this customer data and storing the encrypted data in mySQL. Today, I'm thinking "what's the point." It's like having a lockbox with the key on the wall above...
My thoughts: What do you all think? Sorry for my bad english. I am not from around these parts.
whats the diff between echo,print,print_r what's the difference between include(),require,require_once Hi All, being a noob when it comes to any sort of coding I am facing a strong learning curve but I'm getting there. With the implementation of our new client portal, we require a new client sign-up api...The following was provided... <?php ////////////////////////////////////////////////////// // THIS CODE IS PROVIDED AS AN EXAMPLE OF HOW TO // USE THE DITTO PORTAL FOR AHSAY API'S. ////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // SET API VARIABLES ///////////////////////////////////////////////////////////////// //SET CUSTOMER ID AND API KEY $customerID = '8000003'; $key = '6NbTmZw5LZdtTO8FuYH9G'; //IF POSTBACK if ($_SERVER['REQUEST_METHOD'] == 'POST') { ///////////////////////////////////////////////////////////////// // GET VALUES FROM FORM ///////////////////////////////////////////////////////////////// $company = $_REQUEST['company']; $address1 = $_REQUEST['address1']; $address2 = $_REQUEST['address2']; $city = $_REQUEST['city']; $state = $_REQUEST['state']; $postal = $_REQUEST['postal']; $country = $_REQUEST['country']; $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; $phone = $_REQUEST['phone']; $email = $_REQUEST['email']; $type = $_REQUEST['type']; $username = $_REQUEST['username']; $alias = $_REQUEST['alias']; $language = $_REQUEST['language']; $timezone = $_REQUEST['timezone']; ///////////////////////////////////////////////////////////////// // INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListCountries'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries'; //MAKE API CALL USING SIMPLE XML $countrylist = simplexml_load_file($url); foreach ($countrylist as $c) { if ($country == $c->countryID) { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\" selected>".$c->countryName.""; } else { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName.""; } } ///////////////////////////////////////////////////////////////// // INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListLanguages'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages'; //MAKE API CALL USING SIMPLE XML $languagelist = simplexml_load_file($url); foreach ($languagelist as $l) { if ($language == $l->languageID) { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\" selected>".$l->languageName.""; } else { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName.""; } } ///////////////////////////////////////////////////////////////// // INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListTimezones'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones'; //MAKE API CALL USING SIMPLE XML $timezonelist = simplexml_load_file($url); foreach ($timezonelist as $t) { if ($timezone == $t->timezoneID) { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\" selected>".$t->timezoneName.""; } else { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName.""; } } ///////////////////////////////////////////////////////////////// // BEFORE CALLING THE ADDCLIENT API, YOU SHOULD VALIDATE THE // USER'S INPUT (ALL REQUIRED FIELDS COMPLETE, EMAIL ADDRESS // ETC. ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // INVOKE ADD CLIENT API TO ACTIVATE ACCOUNT ///////////////////////////////////////////////////////////////// //SET ACCOUNT TYPE AND TRIAL LENGTH $account = 'TRIAL'; $length = '14'; //BUILD URL FOR API CALL $function = 'AddClient'; $url = 'https://api.web-portal.co/?'. "customerID=".$customerID. "&key=".$key. "&function=".$function. "&company=".$company. "&address1=".$address1. "&address2=".$address2. "&city=".$city. "&state=".$state. "&postal=".$postal. "&country=".$country. "&firstname=".$firstname. "&lastname=".$lastname. "&phone=".$phone. "&email=".$email. "&type=".$type. "&username=".$username. "&alias=".$alias. "&language=".$language. "&timezone=".$timezone. "&account=".$account. "&length=".$length; //MAKE API CALL USING SIMPLE XML $createClient = simplexml_load_file($url); //DISPLAY RESULTS OF API CALL echo $createClient; } //NOT POSTBACK else { ///////////////////////////////////////////////////////////////// // INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListCountries'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries'; //MAKE API CALL USING SIMPLE XML $countrylist = simplexml_load_file($url); foreach ($countrylist as $c) { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName.""; } ///////////////////////////////////////////////////////////////// // INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListLanguages'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages'; //MAKE API CALL USING SIMPLE XML $languagelist = simplexml_load_file($url); foreach ($languagelist as $l) { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName.""; } ///////////////////////////////////////////////////////////////// // INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListTimezones'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones'; //MAKE API CALL USING SIMPLE XML $timezonelist = simplexml_load_file($url); foreach ($timezonelist as $t) { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName.""; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <p>NEW CLIENT SIGN UP</p> <form id="NewClientForm" name="NewClientForm" method="post" action="NewClientForm.php"> <p>Company Name:<br /> <label for="company"></label> <input type="text" name="company" id="company" value="<? echo $company; ?>" /> </p> <p>Address 1:<br /> <label for="address1"></label> <input type="text" name="address1" id="address1" value="<? echo $address1; ?>" /> </p> <p>Address 2:<br /> <label for="address2"></label> <input type="text" name="address2" id="address2" value="<? echo $address2; ?>" /> </p> <p>City:<br /> <label for="city"></label> <input type="text" name="city" id="city" value="<? echo $city; ?>" /> </p> <p>State/Province:<br /> <label for="state"></label> <input type="text" name="state" id="state" value="<? echo $state; ?>" /> </p> <p>Zip/Postal Code:<br /> <label for="postal"></label> <input type="text" name="postal" id="postal" value="<? echo $postal; ?>" /> </p> <p>Country:<br /> <label for="country"></label> <select name="country" id="country"> <? echo $countryOptions; ?> </select> </p> <p>Primary Contact First Name:<br /> <label for="firstname"></label> <input type="text" name="firstname" id="firstname" value="<? echo $firstname; ?>" /> </p> <p>Primary Contact Last Name:<br /> <label for="lastname"></label> <input type="text" name="lastname" id="lastname" value="<? echo $lastname; ?>" /> </p> <p>Primary Contact Telephone:<br /> <label for="phone"></label> <input type="text" name="phone" id="phone" value="<? echo $phone; ?>" /> </p> <p>Primary Contact Email:<br /> <label for="email"></label> <input type="text" name="email" id="email" value="<? echo $email; ?>" /> </p> <p>Account Type:<br /> <input type="radio" name="type" id="acb" value="ACB" /> <label for="acb">ACB</label> <input type="radio" name="type" id="obm" value="OBM" /> <label for="obm">OBM</label> </p> <p>Preferred Username:<br /> <label for="username"></label> <input type="text" name="username" id="username" value="<? echo $username; ?>" /> </p> <p>Alias/Nickname:<br /> <label for="alias"></label> <input type="text" name="alias" id="alias" value="<? echo $alias; ?>" /> </p> <p>Language:<br /> <label for="language"></label> <select name="language" id="language"> <? echo $languageOptions; ?> </select> </p> <p>Timezone:<br /> <label for="timezone"></label> <select name="timezone" id="timezone"> <? echo $timezoneOptions; ?> </select> </p> <p> </p> <p> <input type="submit" name="submit" id="submit" value="Sign Up" /> </p> </form> <p><br /> </p> </body> </html> The following errors are produced... http://cubetech.com.au/downloads/signup.php Can please confirm my suspicions of simplexml_load_file() are not permitted. I have been reading about cURL implementation instead can someone provide some assistance if this is possible and assist. A lot of thank in advance, Andrew Chapman Friends, suppose iam copying 1 to 100 files using a loop in php & when the copy process reach at 50th file my browser went offline. My doubt is will it copy all 100 files ?? OR it will terminate at 50th file ? if i want to get all files copied if the browser went offline then what i want to do ?? Please clear I am trying to run tests on my pages and see how much time each one of em take to execute. For this purpose, i'm using this code which i got online: Code: [Select] <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; ?> <!-- Rest of the php and validation and form elements --> <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "This page was created in ".$totaltime." seconds"; ?> microtime() returns microseconds & secs since Unix epoch. So after exploding, why do we add them both? Cant we just use the microseconds part? I've tried this code & the one above & both return same time(almost). Code: [Select] <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[0]; $starttime = $mtime; ?> <!-- Rest of the php and validation and form elements --> <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "This page was created in ".$totaltime." seconds"; ?> Hi all, Can anyone offer assistance with the following: I am trying to obtain a score from a users radio button selection on a simple quiz. i am not able to obtain the results.... I'm not sure if this is exactly a coding help question, excuse me if its not. I want to know what is the best & secure way to submit a form to itself. I've tried to google the answer, but did not get a proper answer with explanation or may be I didnt use proper keywords to search it. Out of these which one do i use? Code: [Select] // Leave the action field empty. <form method="POST" action=""> //$PHP_SELF, also if i use echo $PHP_SELF my form does not work like it should. <form method="POST" action="<?$PHP_SELF?>"> //$_SERVER['PHP_SELF'], same problem as $PHP_SELF, it doesnt work if i use echo. <form method="POST" action="<?$_SERVER['PHP_SELF']?>"> I have a php code that call a process (a java program). The process runs in background for a so long time - from 1 minute to 2 hours. I make the process call using exec:
<?php function execInBackground($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . " &> /dev/null &"); } } $command = "java ... ReadEmailsCmdLine 2>&1"; execInBackground($command); echo "FINALIZADO";Though the command runs in background it looks that the PHP code wait for the command completion to send a answer to client browser because I just see "FINALIZADO" after the java program finished its execution. Does someone know how I can solve this problem? Or at least does have a hint/pointer for that? Since now I thanks any comment/suggestion Hi all. i have problems with making a questionnaire. i have done a single questions but i have no idea how to add them al ltogether so they work as switch function. i`ve attached one of the questions. could anyone suggest how i make answers into a list rather than just a line of options? Hi there, trying to use PCNTL. I've recompiled PHP with --enable-pcntl in configure as described in PHP manual, but when I call pcntl_fork() I receive back " Fatal error: Call to undefined function pcntl_fork() ". What am I missing??? Thanks in advance Muflo PHP v. 5.3.8 What is libxml extension and how would I know if it's enabled? My book told me Note To take advantage of SimpleXML, make sure PHP's libxml extension is enabled. I have a variable that holds the name of a File... Code: [Select] $origFileName = $_FILES['userPhoto']['name']; What is the best way to just get the File Name from this? Debbie |