def read_private_key(key_path, **kwargs):
    """Helper function to return private key read from .pem file."""

    _open = kwargs.get('opener') or open  # For testing with StringIO or BytesIO

    with _open(key_path) as kf:
        return kf.read()