code: public static Set<String> extractApnsTopics(X509Certificate certificate) throws IOException {
          Set<String> topics = new HashSet<>();
  
          for (String keyValuePair : certificate.getSubjectX500Principal().getName().split(",")) {
              if (keyValuePair.toLowerCase().startsWith(PREFIX_UID)) {
                  topics.add(keyValuePair.substring(PREFIX_UID.length()));
                  break;
              }
          }
  
          byte[] topicExtensionData = certificate.getExtensionValue(TOPIC_OID);
  
          if (topicExtensionData != null) {
              ASN1Primitive extensionValue = JcaX509ExtensionUtils.parseExtensionValue(topicExtensionData);
  
              if (extensionValue instanceof ASN1Sequence) {
                  for (Object object : (ASN1Sequence) extensionValue) {
                      if (object instanceof ASN1String) {
                          topics.add(String.valueOf(object));
                      }
                  }
              }
          }
  
          return topics;
      }
docs: Extract topics for sending push notifications from {@link X509Certificate} certificate.
  
  @param certificate {@link X509Certificate} instance.
  @return unique {@link Set} of topics from a certificate
  @throws IOException
  If {@link X509Certificate} parsing failed.