def getAPNTopicFromX509(x509):
    """
    Given an L{X509} certificate, extract the UID value portion of the
    subject, which in this context is used for the associated APN topic.

    @param x509: the certificate
    @type x509: L{X509}

    @return: C{str} topic, or empty string if value is not found
    """
    subject = x509.get_subject()
    components = subject.get_components()
    for name, value in components:
        if name == "UID":
            return value
    return ""