{"record":{"id":"6f3f3c701ab4006b","repo":"shadow1ng/fscan","slug":"tls-conn-does-not-exist","errorCode":null,"errorMessage":"TLS conn does not exist","messagePattern":"TLS conn does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/grdp/core/socket.go","lineNumber":70,"sourceCode":"func (s *SocketLayer) StartTLS() error {\n\tconfig := &tls.Config{\n\t\tInsecureSkipVerify:       true,\n\t\tMinVersion:               tls.VersionTLS10,\n\t\tMaxVersion:               tls.VersionTLS13,\n\t\tPreferServerCipherSuites: true,\n\t}\n\ts.tlsConn = tls.Client(s.conn, config)\n\treturn s.tlsConn.Handshake()\n}\n\ntype PublicKey struct {\n\tN *big.Int `asn1:\"explicit,tag:0\"` // modulus\n\tE int      `asn1:\"explicit,tag:1\"` // public exponent\n}\n\nfunc (s *SocketLayer) TlsPubKey() ([]byte, error) {\n\tif s.tlsConn == nil {\n\t\treturn nil, errors.New(\"TLS conn does not exist\")\n\t}\n\tcerts := s.tlsConn.ConnectionState().PeerCertificates\n\tif len(certs) == 0 {\n\t\treturn nil, errors.New(\"no peer certificates\")\n\t}\n\tpub, ok := certs[0].PublicKey.(*rsa.PublicKey)\n\tif !ok {\n\t\treturn nil, errors.New(\"invalid public key type\")\n\t}\n\treturn asn1ber.Marshal(*pub)\n}\n","sourceCodeStart":52,"sourceCodeEnd":82,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/libs/grdp/core/socket.go#L52-L82","documentation":"Guard in SocketLayer.TlsPubKey: it needs the server's TLS certificate public key for RDP NLA/CredSSP, but s.tlsConn is nil because StartTLS() was never called (or failed) before extracting the peer public key.","triggerScenarios":"Thrown at libs/grdp/core/socket.go:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call SocketLayer.StartTLS() and confirm Handshake() returned nil before TlsPubKey()","If the handshake failed, address the underlying TLS error (protocol version, network) first","Skip NLA negotiation and fall back to standard RDP security if CredSSP is not required"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}