code: private void checkPair() throws CertificateException {
  
          /* if either of pair is missing, return w/o error */
          if (forward == null || reverse == null) {
              return;
          }
          /*
           * If both elements of the pair are present, check that they
           * are a valid pair.
           */
          X500Principal fwSubject = forward.getSubjectX500Principal();
          X500Principal fwIssuer = forward.getIssuerX500Principal();
          X500Principal rvSubject = reverse.getSubjectX500Principal();
          X500Principal rvIssuer = reverse.getIssuerX500Principal();
          if (!fwIssuer.equals(rvSubject) || !rvIssuer.equals(fwSubject)) {
              throw new CertificateException("subject and issuer names in "
                  + "forward and reverse certificates do not match");
          }
  
          /* check signatures unless key parameters are missing */
          try {
              PublicKey pk = reverse.getPublicKey();
              if (!(pk instanceof DSAPublicKey) ||
                          ((DSAPublicKey)pk).getParams() != null) {
                  forward.verify(pk);
              }
              pk = forward.getPublicKey();
              if (!(pk instanceof DSAPublicKey) ||
                          ((DSAPublicKey)pk).getParams() != null) {
                  reverse.verify(pk);
              }
          } catch (GeneralSecurityException e) {
              throw new CertificateException("invalid signature: "
                  + e.getMessage());
          }
      }
docs: /*
  Check for a valid certificate pair