def _check_type_and_load_cert(self, msg, key_type, cert_type):
<EOL>key_types = key_type<EOL>cert_types = cert_type<EOL>if isinstance(key_type, string_types):<EOL><INDENT>key_types = [key_types]<EOL><DEDENT>if isinstance(cert_types, string_types):<EOL><INDENT>cert_types = [cert_types]<EOL><DEDENT>if msg is None:<EOL><INDENT>raise SSHException("<STR_LIT>")<EOL><DEDENT>msg.rewind()<EOL>type_ = msg.get_text()<EOL>if type_ in key_types:<EOL><INDENT>pass<EOL><DEDENT>elif type_ in cert_types:<EOL><INDENT>self.load_certificate(Message(msg.asbytes()))<EOL>msg.get_string()<EOL><DEDENT>else:<EOL><INDENT>err = "<STR_LIT>"<EOL>raise SSHException(err.format(self.__class__.__name__, type_))<EOL><DEDENT>
Perform message type-checking & optional certificate loading.

This includes fast-forwarding cert ``msg`` objects past the nonce, so
that the subsequent fields are the key numbers; thus the caller may
expect to treat the message as key material afterwards either way.

The obtained key type is returned for classes which need to know what
it was (e.g. ECDSA.)