title: OpenLdap - error in SSLv2/v3 read server hello A
body: <p>I need to connect ApacheDS database using startTLS with OpenLDAP client.
  My ldaprc file contains:</p>
  
  <pre><code>URI ldap://127.0.0.1:7323 ldaps://127.0.0.1:7423
  SSL start_tls
  SASL_MECH plain
  TLSCipherSuite HIGH:MEDIUM:+TLSv1:!SSLv2:+SSLv3
  TLS_REQCERT allow
  </code></pre>
  
  <p>Command that I've used is:</p>
  
  <pre><code>ldapsearch -H ldap://localhost:7323 -D "uid=admin,ou=system" -w secret -Z -d1
  </code></pre>
  
  <p>I've checked, my server is listening on these ports, I'm able to connect with other clients (e.g. ldapbrowser, jxplorer), but tests with OpenLdap fails:</p>
  
  <p>...<br /></p>
  
  <blockquote>
    <p>ldap_connect_to_host: Trying 127.0.0.1:7323<br /> ldap_pvt_connect:
    fd: 3 tm: -1 async: 0<br /> ldap_open_defconn: successful<br />
    ldap_send_server_request<br /> ber_scanf fmt ({it) ber:<br />
    ber_scanf fmt ({) ber:<br /> ber_flush2: 31 bytes to sd 3<br />
    ldap_result ld 0x7f81d95282a0 msgid 1<br /> wait4msg ld 0x7f81d95282a0
    msgid 1 (infinite timeout)<br /> wait4msg continue ld 0x7f81d95282a0
    msgid 1 all 1<br />
    ** ld 0x7f81d95282a0 Connections:<br />
    * host: 127.0.0.1  port: 7323  (default)<br />   refcnt: 2  status: Connected<br />   last used: Tue Dec  8 09:51:45 2015<br /></p>
    
    <p>** ld 0x7f81d95282a0 Outstanding Requests:<br />  * msgid 1,  origid 1, status InProgress<br />    outstanding referrals 0, parent count
    0<br />   ld 0x7f81d95282a0 request count 1 (abandoned 0)<br />
    ** ld 0x7f81d95282a0 Response Queue:<br />    Empty<br />   ld 0x7f81d95282a0 response count 0<br /> ldap_chkResponseList ld
    0x7f81d95282a0 msgid 1 all 1<br /> ldap_chkResponseList returns ld
    0x7f81d95282a0 NULL<br /> ldap_int_select<br /> read1msg: ld
    0x7f81d95282a0 msgid 1 all 1<br /> ber_get_next<br /> ber_get_next:
    tag 0x30 len 38 contents:<br /> read1msg: ld 0x7f81d95282a0 msgid 1
    message type extended-result<br /> ber_scanf fmt ({eAA) ber:<br />
    read1msg: ld 0x7f81d95282a0 0 new referrals<br /> read1msg:  mark
    request completed, ld 0x7f81d95282a0 msgid 1<br /> request done: ld
    0x7f81d95282a0 msgid 1<br /> res_errno: 0, res_error: &lt;>, res_matched:
    &lt;><br /> ldap_free_request (origid 1, msgid 1)<br />
    ldap_parse_extended_result<br /> ber_scanf fmt ({eAA) ber:<br />
    ber_scanf fmt (a) ber:<br /> ber_scanf fmt (O) ber:<br />
    ldap_parse_result<br /> ber_scanf fmt ({iAA) ber:<br /> ber_scanf fmt
    (x) ber:<br /> ber_scanf fmt (x) ber:<br /> ber_scanf fmt (}) ber: ldap_msgfree<br /> TLS trace: SSL_connect:before/connect
    initialization<br /> TLS trace: SSL_connect:SSLv2/v3 write client
    hello A<br /> TLS trace: SSL3 alert read:fatal:unexpected_message TLS trace: SSL_connect:error in SSLv2/v3 read server hello A<br />
    TLS: can't connect: error:140773F2:SSL
    routines:SSL23_GET_SERVER_HELLO:sslv3 alert unexpected message.<br />
    ldap_err2string<br /> ldap_start_tls: Connect error (-11)<br />
            additional info: error:140773F2:SSLroutines:SSL23_GET_SERVER_HELLO:sslv3 alert
    unexpected message</p>
  </blockquote>
  
  <p>Any idea what am I doing wrong or what am I missing?</p>