def getPublicKey(registry=None):
registry = registry or Registry_Base_URL<EOL>pubkey_pem = None<EOL>if _isPublicRegistry(registry):<EOL><INDENT>pubkey_pem = settings.getProperty('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>for s in _getSources():<EOL><INDENT>if _sourceMatches(s, registry):<EOL><INDENT>if '<STR_LIT>' in s and s['<STR_LIT>'] and '<STR_LIT>' in s['<STR_LIT>']:<EOL><INDENT>pubkey_pem = s['<STR_LIT>']['<STR_LIT>']<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if not pubkey_pem:<EOL><INDENT>pubkey_pem, privatekey_pem = _generateAndSaveKeys()<EOL><DEDENT>else:<EOL><INDENT>pubkey_pem = pubkey_pem.encode('<STR_LIT:ascii>')<EOL><DEDENT>if b'<STR_LIT>' in pubkey_pem:<EOL><INDENT>pubkey = serialization.load_pem_public_key(pubkey_pem, default_backend())<EOL><DEDENT>else:<EOL><INDENT>pubkey_der = binascii.unhexlify(pubkey_pem)<EOL>pubkey = serialization.load_der_public_key(pubkey_der, default_backend())<EOL><DEDENT>return _pubkeyWireFormat(pubkey)<EOL>
Return the user's public key (generating and saving a new key pair if necessary)