Re: [PHP] Command line socket server and SSL
Below you have described a client. I'm talking about a server. That was clear in my original post. -Paul W Greg Donald wrote: On Tue, 4 Sep 2007, Paul wrote: Which part do you need help with? The SSL part or the command line or the port or ... ? http://www.php.net/openssl http://www.php.net/sockets I am familiar with the above links. What I cannot locate is anything that indicates that a cmd line socket program in PHP can do SSL. Can you locate such? Is it in the openssl document somewhere and I missed it? Whether the script is command line or not has nothing to do with it's ability to connect to a host on a specific port. You just connect to the port the secure socket is located on, usually 443. #!/usr/bin/env php ?php $s = socket_create( AF_INET, SOCK_STREAM, SOL_TCP ); socket_set_nonblock( $s ); socket_connect( $s, example.com, 443 ); socket_set_block( $s ); switch( socket_select( $r = array( $s ), $w = array( $s ), $f = array( $s ), 5 ) ) { case 2: echo [-] Connection Refused\n; break; case 1: echo [+] Connected\n; break; case 0: echo [-] Timeout\n; break; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command line socket server and SSL
On Wed, 5 Sep 2007, Paul wrote: Below you have described a client. I'm talking about a server. That was clear in my original post. Why on earth would you need to implement an SSL socket in PHP when we have Apache and openssl? That's pointless. Anywhere PHP can run Apache can run.. and with much better performance. -- Greg Donald Cyberfusion Consulting http://cyberfusionconsulting.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command line socket server and SSL
Greg Donald wrote: On Wed, 5 Sep 2007, Paul wrote: Below you have described a client. I'm talking about a server. That was clear in my original post. Why on earth would you need to implement an SSL socket in PHP when we have Apache and openssl? That's pointless. Anywhere PHP can run Apache can run.. and with much better performance. Because the client is incapable of HTTPS or HTTP protocols. Not that I really should need to answer this. Why on earth would you assume I don't have a good reason? In what way is this answer to my question even a little helpful? Do you have anything to offer in answer to my question to the list that actually might help? Paul W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command line socket server and SSL
Paul wrote: Why on earth would you need to implement an SSL socket in PHP when we have Apache and openssl? That's pointless. Anywhere PHP can run Apache can run.. and with much better performance. Because the client is incapable of HTTPS or HTTP protocols. Not that I really should need to answer this. Why on earth would you assume I don't have a good reason? In what way is this answer to my question even a little helpful? I'm sorry, I can't offer any help for doing it in PHP, but why do you have to? Why not just do it in C, and use the openssl library. But if it has to be PHP, see if you can find some PHPopenssl bindings. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command line socket server and SSL
On 9/5/07, Paul [EMAIL PROTECTED] wrote: Greg Donald wrote: Why on earth would you need to implement an SSL socket in PHP when we have Apache and openssl? That's pointless. Anywhere PHP can run Apache can run.. and with much better performance. Because the client is incapable of HTTPS or HTTP protocols. Disclaimer - I'm still something of a PHP newbie, so please do not take this as definitive or authoritative advice, but hopefully you'll still find it helpful. My guess is that you won't find a way to create an SSL server socket in PHP, as most PHP use is web-facing - all the SSL details on that end would be handled by the web server (Apache, IIS, etc.) before the PHP interpreter fires up. My best suggestion for you would be to use stunnel (http://stunnel.org/) or something similar to handle the SSL details of the server connection and pass the actual data on to your server's socket - it's pretty straightforward to use. Hope this helps. Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command line socket server and SSL
On Wed, 5 Sep 2007, Paul wrote: Because the client is incapable of HTTPS or HTTP protocols. Not that I really should need to answer this. Why on earth would you assume I don't have a good reason? In what way is this answer to my question even a little helpful? It's not every day someone wants to use php with openssl but omit the web server component. Do you have anything to offer in answer to my question to the list that actually might help? Have you tried using the openssl s_server directly? -- Greg Donald Cyberfusion Consulting http://cyberfusionconsulting.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command line socket server and SSL
Greg Donald wrote: On Wed, 5 Sep 2007, Paul wrote: Because the client is incapable of HTTPS or HTTP protocols. Not that I really should need to answer this. Why on earth would you assume I don't have a good reason? In what way is this answer to my question even a little helpful? It's not every day someone wants to use php with openssl but omit the web server component. Do you have anything to offer in answer to my question to the list that actually might help? Have you tried using the openssl s_server directly? Worth a look. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Command line socket server and SSL
I need to program a socket server in PHP that can use a certificate and communicate over SSL. I'm doing fine without SSL. Can't use port 443 or the web server for this, so it needs to be a command line app. Can't seem to find any documentation about how to set that up. Can anyone help or point me in the right direction? TIA, Paul W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command line socket server and SSL
Paul wrote: I need to program a socket server in PHP that can use a certificate and communicate over SSL. I'm doing fine without SSL. Can't use port 443 or the web server for this, so it needs to be a command line app. Can't seem to find any documentation about how to set that up. Can anyone help or point me in the right direction? Which part do you need help with? The SSL part or the command line or the port or ... ? http://www.php.net/openssl http://www.php.net/sockets -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command line socket server and SSL
Chris wrote: Paul wrote: I need to program a socket server in PHP that can use a certificate and communicate over SSL. I'm doing fine without SSL. Can't use port 443 or the web server for this, so it needs to be a command line app. Can't seem to find any documentation about how to set that up. Can anyone help or point me in the right direction? Which part do you need help with? The SSL part or the command line or the port or ... ? http://www.php.net/openssl http://www.php.net/sockets I am familiar with the above links. What I cannot locate is anything that indicates that a cmd line socket program in PHP can do SSL. Can you locate such? Is it in the openssl document somewhere and I missed it? Paul W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Command line socket server and SSL
On Tue, 4 Sep 2007, Paul wrote: Which part do you need help with? The SSL part or the command line or the port or ... ? http://www.php.net/openssl http://www.php.net/sockets I am familiar with the above links. What I cannot locate is anything that indicates that a cmd line socket program in PHP can do SSL. Can you locate such? Is it in the openssl document somewhere and I missed it? Whether the script is command line or not has nothing to do with it's ability to connect to a host on a specific port. You just connect to the port the secure socket is located on, usually 443. #!/usr/bin/env php ?php $s = socket_create( AF_INET, SOCK_STREAM, SOL_TCP ); socket_set_nonblock( $s ); socket_connect( $s, example.com, 443 ); socket_set_block( $s ); switch( socket_select( $r = array( $s ), $w = array( $s ), $f = array( $s ), 5 ) ) { case 2: echo [-] Connection Refused\n; break; case 1: echo [+] Connected\n; break; case 0: echo [-] Timeout\n; break; } -- Greg Donald Cyberfusion Consulting http://cyberfusionconsulting.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php