@@ -93,7 +93,8 @@ public function hostAction()
9393 ->columns ([new Expression ('MAX(GREATEST(%s, %s)) ' , ['valid_from ' , 'issuer_certificate.valid_from ' ])])
9494 ->getSelectBase ()
9595 ->resetWhere ()
96- ->where (new Expression ('sub_certificate_link.certificate_chain_id = target_chain.id ' ));
96+ ->where (new Expression ('sub_certificate_link.certificate_chain_id = target_chain.id ' ))
97+ ->where (new Expression ("sub_certificate.self_signed != 'y' " ));
9798
9899 // Sub query for `valid_to` column
99100 $ validTo = $ targets ->createSubQuery (new X509Certificate (), 'chain.certificate ' );
@@ -102,16 +103,22 @@ public function hostAction()
102103 ->getSelectBase ()
103104 // Reset the where clause generated within the createSubQuery() method.
104105 ->resetWhere ()
105- ->where (new Expression ('sub_certificate_link.certificate_chain_id = target_chain.id ' ));
106+ ->where (new Expression ('sub_certificate_link.certificate_chain_id = target_chain.id ' ))
107+ ->where (new Expression ("sub_certificate.self_signed != 'y' " ));
106108
107109 list ($ validFromSelect , $ _ ) = $ validFrom ->dump ();
108110 list ($ validToSelect , $ _ ) = $ validTo ->dump ();
109111 $ targets
110112 ->withColumns ([
111- 'valid_from ' => new Expression ($ validFromSelect ),
112- 'valid_to ' => new Expression ($ validToSelect )
113+ 'valid_from ' => new Expression (
114+ sprintf ('COALESCE((%s), target_chain_certificate.valid_from) ' , $ validFromSelect )
115+ ),
116+ 'valid_to ' => new Expression (
117+ sprintf ('COALESCE((%s), target_chain_certificate.valid_to) ' , $ validToSelect )
118+ )
113119 ])
114120 ->getSelectBase ()
121+ ->distinct ()
115122 ->where (new Expression ('target_chain_link.order = 0 ' ));
116123
117124 if ($ ip !== null ) {
0 commit comments