PHP 8.4.0 RC3 available for testing

Genel Ağ Alanı: TCP, UDP, SSL ve TLS

ssl://, tls://, sslv2:// ve sslv3:// desteklenmektedir.

Bilginize: Hiçbir aktarım belirtilmezse tcp:// öntanımlıdır.

  • 127.0.0.1
  • fe80::1
  • mesela.dom
  • tcp://127.0.0.1
  • tcp://fe80::1
  • tcp://mesela.dom
  • udp://mesela.dom
  • ssl://mesela.dom
  • sslv2://mesela.dom
  • sslv3://mesela.dom
  • tls://mesela.dom

Genel Ağ Alanının soketleri bir hedef adrese ek olara bir port numarası gerektirirler. fsockopen() işlevi için bu ikinci bir bağımsız değişken ile belirtilir, dolayısıyla port numarasının IP adresiyle birlikte bir aktarım URLsi olarak biçimlenmesine gerek kalmaz. stream_socket_client() ve ilgili diğer işlevler için ise geleneksel URL gösterimi kullanılır, yani port numarası aktarım URL'sinin sonuna iki nokta imi ile eklemlenir.

  • tcp://127.0.0.1:80
  • tcp://[fe80::1]:80
  • tcp://mesela.dom:80

Bilginize: Port numaralı IPv6 adresleri
Dikkat ederseniz, yukarıdaki örneklerden ikincisinde IPv6 adresi köşeli ayraçlarını arasına alınmıştır ([fe80::1]). Bunun sebebi IPv6 adresin iki noktalı ayraçlarının, port numarasını eklemleyen iki nokta iminden ayırd edilmesini sağlamaktır.

ssl:// ve tls:// aktarımları (sadece PHP openssl desteği ile derlenmişse vardırlar) tcp:// aktarımının SSL şifrelemeli uzantılarıdır.

ssl:// aktarımı, uzak konağın yetenek ve tercihlerine bağlı olarak SSL V2 veya SSL V3 bağlantısı kurmaya çalışacaktır. SSL V2 veya SSL V3 bağlantı istekleri sslv2:// ve sslv3:// biçeminde açıkça belirtilebilir.

add a note

User Contributed Notes 2 notes

up
16
christian at lantian dot eu
11 years ago
@pablo dot livardo : I think that the problem you found is caused by the difference between the client/server encryption methods used.

The 465 port is used for SMTPS, and the server starts the encryption immediately it receives your connection. So, your code will work.

The 587 port is used for Submission (MSA or Mail Submission Agent) which works like the port 25. The server accepts your connection and doesn't activate the encryption. If you want an encrypted connection on the port 587, you must connect on it without encryption, you must start to dialog with the server (with EHLO) and after that you must ask the server to start the encrypted connection using the STARTTLS command. The server starts the encryption and now you can start as well the encryption on your client.

So, in few words, you can not use :

<?php $fp = fsockopen("tls://mail.example.com", 587, $errno, $errstr); ?>

but you can use:

<?php $fp = stream_socket_client("mail.example.com:587", $errno, $errstr); ?>

and after you send the STARTTLS command, you can enable the crypto:

<?php stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT); ?>

P.S. My previous note on this page was totally wrong, so I ask the php.net admin to remove it.

:)
up
6
stefan at example dot com
14 years ago
Actually, PHP is very able to start with an unencrypted connection and then switch to an encrypted one - refer to http://php.net/stream_socket_enable_crypto .
To Top