def _configure_context_for_negotiation(context, inner_protocols):
    """
    Given a PEP 543 list of protocols to negotiate, configures the SSLContext
    to negotiate those protocols.
    """
    if inner_protocols:
        protocols = []
        for np in inner_protocols:
            proto_string = np if isinstance(np, bytes) else np.value
            # The protocol string needs to be of type str for the standard
            # library.
            protocols.append(proto_string.decode('ascii'))

        # If ALPN/NPN aren't supported, that's no problem.
        try:
            context.set_alpn_protocols(protocols)
        except NotImplementedError:
            pass

        try:
            context.set_npn_protocols(protocols)
        except NotImplementedError:
            pass

    return context