def create_binary_security_token(key_file):
node = etree.Element(<EOL>ns_id('<STR_LIT>', ns.wssens),<EOL>nsmap={ns.wssens[<NUM_LIT:0>]: ns.wssens[<NUM_LIT:1>]})<EOL>node.set(ns_id('<STR_LIT>', ns.wsuns), get_unique_id())<EOL>node.set('<STR_LIT>', ns.wssns[<NUM_LIT:1>] + '<STR_LIT>')<EOL>node.set('<STR_LIT>', BINARY_TOKEN_TYPE)<EOL>with open(key_file) as fh:<EOL><INDENT>cert = crypto.load_certificate(crypto.FILETYPE_PEM, fh.read())<EOL>node.text = base64.b64encode(<EOL>crypto.dump_certificate(crypto.FILETYPE_ASN1, cert))<EOL><DEDENT>return node<EOL>
Create the BinarySecurityToken node containing the x509 certificate.