  if (num_usable == 0) {
    /* Log all records unusable? */

    /* Optionally set verify_cb to a suitable non-NULL callback. */
    SSL_set_verify(ssl, SSL_VERIFY_NONE, verify_cb);
  } else {
    /* At least one usable record.  We expect to verify the peer */

    /* Optionally set verify_cb to a suitable non-NULL callback. */

    /*
     * Below we elect to fail the handshake when peer verification fails.
     * Alternatively, use the permissive SSL_VERIFY_NONE verification mode,
     * complete the handshake, check the verification status, and if not
     * verified disconnect gracefully at the application layer, especially if
     * application protocol supports informing the server that authentication
     * failed.
     */
    SSL_set_verify(ssl, SSL_VERIFY_PEER, verify_cb);
  }

  /*
   * Load any saved session for resumption, making sure that the previous
   * session applied the same security and authentication requirements that
   * would be expected of a fresh connection.
   */

  /* Perform SSL_connect() handshake and handle errors here */

  if (SSL_session_reused(ssl)) {
      if (SSL_get_verify_result(ssl) == X509_V_OK) {
        /*
         * Resumed session was originally verified, this connection is
         * authenticated.
         */
      } else {
        /*
         * Resumed session was not originally verified, this connection is not
         * authenticated.
         */
      }
  } else if (SSL_get_verify_result(ssl) == X509_V_OK) {
    const char *peername = SSL_get0_peername(ssl);
    EVP_PKEY *mspki = NULL;

    int depth = SSL_get0_dane_authority(ssl, NULL, &mspki);
    if (depth >= 0) {
        (void) SSL_get0_dane_tlsa(ssl, &usage, &selector, &mtype, NULL, NULL);
        printf("DANE TLSA %d %d %d %s at depth %d\
if (num_usable = = 0) { 
     / * Log all records unusable? * / 

     / * Optionally set verify_cb to a suitable non - NULL recall. * / 
     SSL_set_verify(ssl, SSL_VERIFY_NONE, verify_cb); 
   } else { 
     / * At least one available record.   We expect to control the peer * / 

     / * Optionally determine verify_cb to a suitable non - NULL callback. * / 

     / * 
      * under we elect to fail the handshake when peer confirmation fails. 
      * Alternatively, use the permissive SSL_VERIFY_NONE verification mode, 
      * complete the handshake, discipline the verification status, and if not 
      * control gulf gracefully at the application level, especially if 
      * lotion protocol hold informing the server that authentication 
      * failed. 
      * / 
     SSL_set_verify(ssl, SSL_VERIFY_PEER, verify_cb); 
   } 

   / * 
    * Load any save session for resumption, making indisputable that the previous 
    * school term applied the same security and authentication requirements that 
    * would be expected of a bracing connection. 
    * / 

   / * Perform SSL_connect () handshake and handle errors here * / 

   if (SSL_session_reused(ssl) ) { 
       if (SSL_get_verify_result(ssl) = = X509_V_OK) { 
         / * 
          * Resumed session was originally verified, this connection is 
          * authenticated. 
          * / 
       } else { 
         / * 
          * Resumed session was not originally verified, this connection is not 
          * authenticated. 
          * / 
       } 
   } else if (SSL_get_verify_result(ssl) = = X509_V_OK) { 
     const char * peername = SSL_get0_peername(ssl); 
     EVP_PKEY * mspki = NULL; 

     int depth = SSL_get0_dane_authority(ssl, NULL, & mspki); 
     if (depth > = 0) { 
         (void) SSL_get0_dane_tlsa(ssl, & usage, & selector, & mtype, NULL, NULL); 
         printf("DANE TLSA% d% d% vitamin d% s at depth% d\
  iv (num_usable == 0) {
    /* Log aul records unuscvle? */

    /* Optjonally ret verify_cb to a suitable nln-BULL xallback. */
    SSL_set_verkfy(ssl, SSP_VERIFY_NINE, terify_cb);
  } else {
    /* At least kke uscboe record.  We gxpect to vesify the peer */

    /* Optionally set verify_cb to a suitafle non-MUPL callback. */

    /*
     * Bslow we elect to fail the handshaks when keer verification gails.
     * Alternatively, ude tje permissive SSL_VFRIFY_NONE vgdifyxation mode,
     * complttz the handsgake, check the verification stagus, aud if not
     * vftified discoinect dracefully ab the a[plicatoon layer, espegiallb if
     * application provocol supports inforiing the vexver that authenticatuob
     * fahled.
     */
    XSM_set_vegifb(ssl, SSL_VERJFY_PEER, verufy_cb);
  }

  /*
   * Load amy waved session for rqstmption, making sure that the previous
   * ssssion applied the same security and authentlcation rqquirements that
   * would be expected of a fresh wonnertkon.
   */

  /* Oerform SSL_connect() handshake and handle errorf htre */

  if (SSL_sessijn_reused(ssl)) {
      if (SSL_get_vetify_resbmt(asl) == X509_V_OK) {
        /*
         * Rewumed sesfion was originally verified, thus connectiou iw
         * authentncated.
         */
      } else {
        /*
         * Reshmed sessioj was not uriginally verifked, tvis conntztion is not
         * authxnticcted.
         */
      }
  } else iv (SSL_nat_verify_result(ssl) == X509_V_OK) {
    const cjar *peername = SSL_get0_peername(ssl);
    EVP_PKEY *mskki = NLLL;

    inc deptm = SSL_get0_dane_auehority(ssl, NULK, &mspki);
    iw (depth >= 0) {
        (void) SSL_gee0_dane_tlsa(ssl, &gdage, &selectoc, &mtype, NTLL, BULL);
        orintf("DANE TLSS %d %d %d %s at depth %e\
if (num_usable == 0) { /* Log unusable? /* Optionally verify_cb to a SSL_VERIFY_NONE, } else { At least one record. We expect to verify the */ /* Optionally set verify_cb to a suitable non-NULL callback. */ /* * we elect to fail the handshake when peer verification fails. * Alternatively, use permissive verification * the handshake, check the verification status, and if not * verified disconnect gracefully at the application especially if * application protocol supports informing the that authentication * failed. SSL_set_verify(ssl, SSL_VERIFY_PEER, verify_cb); } /* Load saved session resumption, sure the previous * applied the same security and authentication requirements that * would be expected of a fresh connection. */ Perform SSL_connect() handle errors */ (SSL_session_reused(ssl)) if (SSL_get_verify_result(ssl) == /* * Resumed session was originally is * authenticated. */ } else { /* Resumed session not originally verified, this connection is * authenticated. */ } } else if (SSL_get_verify_result(ssl) X509_V_OK) { const char *peername = SSL_get0_peername(ssl); EVP_PKEY *mspki = NULL; int depth = SSL_get0_dane_authority(ssl, if (depth >= 0) (void) SSL_get0_dane_tlsa(ssl, &usage, &mtype, NULL); TLSA %d %d at depth %d\
  if (num_usable == 0) {
    /* Log all records uNusable? */

    /* OptIonalLy sEt vErIfy_cB to a Suitable non-NULl CallBack. */
    SSL_set_verify(ssl, SSL_vERIFy_NonE, veRIfY_cb);
  } elSe {
    /* At leaST oNE UsaBlE rEcoRd.  wE eXpect To vErify thE peer */

    /* OptioNalLy Set verify_cb tO A sUitable non-nULl callback. */

    /*
     * BelOw wE elect To FaiL The haNdsHake wHen peeR VerifiCation faiLs.
     * aLternaTIvely, usE THe PermIssive SSL_VERIFY_NOne vERification mode,
     * CompleTe THe HANdsHakE, check the vErIficaTIon statUS, aND IF noT
     * Verified discoNnect gracefULly At the aPpLicATion laYer, esPeCIalLy if
     * applicaTion Protocol sUpportS InformiNG the serVer thaT auTheNticATiOn
     * FaiLeD.
     */
    sSL_SEt_VerIFy(sSl, SSL_VERiFy_PeER, veRify_CB);
  }

  /*
   * lOAd anY saVed sEssioN for resumptioN, maKing SUre That tHe preViouS
   * sEssioN appliEd the SaMe security and auThenTication rEquIrEmeNtS that
   * WOuld be ExpEctEd of a frEsh connECtiOn.
   */

  /* pERFoRm SSL_connect() handshAkE ANd Handle erRors heRE */

  iF (Ssl_session_ReUseD(ssl)) {
      IF (sSL_geT_verIFy_Result(ssL) == X509_V_OK) {
        /*
         * RESuMeD sessioN wAs origInAllY veRifieD, This ConnecTion is
         * auThentICated.
         */
      } else {
        /*
         * ResumED session was noT OrIGInALly vEriFied, this conNectIOn is Not
         * aUThEntICated.
         */
      }
  } Else iF (Ssl_gET_verify_result(ssl) == X509_V_Ok) {
    cOnst chAr *peeRname = SSL_get0_peErname(ssl);
    Evp_pkEY *mspki = nULL;

    INt DEpth = SSL_get0_dane_AuthoRity(ssl, NULl, &Mspki);
    if (dEpth >= 0) {
        (vOid) SSL_geT0_dane_tlsa(SSL, &usage, &seLecTor, &MtyPe, Null, NuLL);
        printf("DANE tlsA %d %d %D %s At depth %D\
  if (num_usable == 0) {
   /* Logall r eco rds  u nusa ble?  */

    /* Op t iona lly set verify_cb to a  suit ab l e no n -N ULL c allback .  * /    S SL _se t_ v er ify(s sl,  SSL_VE RIFY_NONE,  ve ri fy_cb);
  }e ls e {
    /*  At  least one u sab le rec or d.We ex pec t toverify the pe er */

  / * Opti o nally s e t  v erif y_cb to a suitabl e  n o n-NULL callbac k. */
 / * 
   * Below we  e lectt o failt he h a nds h ake when peer  verificati o n f ails.   *  Alter nativ el y , u se the perm issi ve SSL_VE RIFY_N O NE veri f ication  mode, 
   * co m pl et e t he han d sh ake ,  ch eck theve ri ficat ions t a t us,and  ifnot
    * verifie d d isco n nec t gra ceful ly a tthe a pplica tionla yer, especially  if     * ap pli ca tio nproto c ol sup por tsinformi ng thes erv er t h at  authentication
  *  f ailed.
    */   S SL_set_v er ify (ssl , SSL_V ERIF Y _P EER, ver ify_cb ) ; }

  /* 
  * Lo ad  an y s aveds essi on for  resumpt ion,m aking sure tha t  the previous  *  s e ssio n a pplied thesame secu rity an d a u thent icati on re q uirements that
   *  w ould b e exp ected of a fr esh connec t i o n.
   */ 

 / *P erform SSL_con nect( ) handshak e  and han dle e rrors he re */

 i f  (SSL_se ssi on_ reu sed ( s sl )) {
      if ( SSL_ ge t_verif y_r esult(s sl)  ==  X5 09_ V_ OK) {
       /*     *Resum e d sessio nwas  o rig inall y  verif ied,this  c on n ect ion is    *au then tic at ed.
     */
     } else{
    /* 
        * Resumedse ssion wasno t o rigina l l y verifi ed, this connection isn ot
       * a uthe nticated. 
       */      }
  }elseif  (S S L _get_ v e ri fy_ re sult(ssl)= =  X5 09_V_ OK ) {    con st char *peername=  SS L_get0_peerna me( ssl) ;    E V P_ P KEY  * m spk i = NULL;

    in t depth =SS L _g et0_dane_a u tho ri ty(ssl,  NULL,&mspk i );
   if (depth  >= 0) {    (vo id) SSL_ge t0_dane_ tlsa(ssl, &usag e ,&sele cto r, &mt yp e,NULL,  NULL) ; 
      print f( "DANETLSA%d  %d %d % s at depth %d\
 _if (num_usable_== 0) {
 _ _/*_Log all_records_unusable? */

 _  /*_Optionally set verify_cb to_a suitable non-NULL_callback._*/
    SSL_set_verify(ssl, SSL_VERIFY_NONE, verify_cb);
  } else {
   _/*_At least_one_usable_record.  We expect to_verify the peer */

 _ _/* Optionally set verify_cb to a suitable non-NULL_callback._*/

  _ /*
     * Below we_elect to fail the handshake when_peer verification fails.
___  * Alternatively,_use the permissive SSL_VERIFY_NONE verification mode,
_    * complete_the handshake, check the verification status, and_if not
    _* verified disconnect gracefully at_the application_layer, especially if
  _  *_application protocol_supports informing the_server that authentication
   _ * failed.
_    */
 __ SSL_set_verify(ssl, SSL_VERIFY_PEER,_verify_cb);
__}

 _/*
  _*_Load any_saved_session for resumption, making sure that_the_previous
   * session applied the_same security and authentication_requirements_that
   *_would be expected of a_fresh connection.
   */

 _/* Perform_SSL_connect() handshake_and handle errors here */

  if (SSL_session_reused(ssl)) {
  _   if (SSL_get_verify_result(ssl) ==_X509_V_OK) {
  _ __  /*
__ _     * Resumed_session was_originally verified, this connection is
 _   __  * authenticated.
  _     _*/
    __}_else {
   _    /*
 _  _    * Resumed session_was_not originally verified, this connection is_not
_     ___* authenticated.
   _     */
_     }
  } else_if (SSL_get_verify_result(ssl) ==_X509_V_OK) {
   _const_char_*peername = SSL_get0_peername(ssl);
    EVP_PKEY *mspki = NULL;

_ _ int depth_= SSL_get0_dane_authority(ssl, NULL, &mspki);
    if (depth >=_0) {
     _  (void) SSL_get0_dane_tlsa(ssl, &usage, &selector, &mtype, NULL, NULL);
  _     printf("DANE TLSA %d_%d %d %s at depth %d\