Home
%3CLINGO-SUB%20id%3D%22lingo-sub-287709%22%20slang%3D%22en-US%22%3EUse%20System.Net%20Trace%20and%20SSL%20Alert%20Protocol%20to%20troubleshoot%20SSL%20connection%20issue.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-287709%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Nov%2005%2C%202012%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3EWCF%20client%20and%20ASMX%20webservice%20client%20all%20use%20the%20System.Net.HttpWebRequest%20object%20to%20create%20underlying%20SSL%20connection.%20If%20you%20experience%20any%20SSL%20related%20problem%2C%20you%20can%20take%20a%20System.Net%20trace%20first.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EIf%20System.Net%20trace%20shows%20the%20pattern%20of%20following%20SSL%20alert%20sequence%2015%2003%2001%2000%2002%2C%20we%20can%20use%20RFC%202246%2C%20%3CA%20href%3D%22http%3A%2F%2Fwww.ietf.org%2Frfc%2Frfc2246.txt%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.ietf.org%2Frfc%2Frfc2246.txt%20%3C%2FA%3E%2C%20section%207.2%20to%20get%20the%20possible%20root%20cause%20of%20SSL%20failure.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESample%20snippet%20in%20System.Net%20trace.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESystem.Ne.Sockets%20Verbose%3A%200%20%3A%20%5B5136%5D%2000000000%20%3A%2015%2003%2001%2000%2002%20%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EStep%201%3A%20Taking%20System.Net%20trace.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E1.)%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Add%20the%20contents%20of%20the%26nbsp%3Blisted%20XML%26nbsp%3Bfile%20to%20your%20application%20configuration%20file.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EIf%20you%20have%20a%20desktop%20application%2C%20the%20configuration%20file%20will%20be%20a%20file%20called%20YourApp.exe.config%20%3CBR%20%2F%3EIf%20it%20is%20an%20asp.net%20application%2C%20the%20configuration%20file%20will%20be%20a%20file%20called%20web.config%20residing%20in%20your%20asp.net%20application%20directory.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E2.)%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Please%20create%20a%20folder%20called%20c%3A%5Ctraces%2C%20and%20give%20full%20permissions%20to%20%E2%80%9CEveryone%E2%80%9D.%20This%20will%20ensure%20that%20the%20log%20will%20get%20created%20regardless%20of%20the%20process%2Fthread%20identity.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E3.)%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Restart%20your%20application%20process%20(YourApp.exe%20for%20desktop%20applications%20and%20w3wp.exe%20for%20asp.net%20applications)%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E4.)%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Reproduce%20the%20problem%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E5.)%26nbsp%3B%26nbsp%3B%26nbsp%3B%20You%20should%20see%20a%20file%20called%20System.Net.trace.log%20in%20the%20c%3A%5Ctraces%20folder.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ENote%3A%20If%20you%20want%20to%20change%20the%20location%20of%20where%20the%20log%20gets%20generated%2C%20you%20can%20do%20it%20by%20changing%20the%20following%20section%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CEM%3E%20initializeData%3D%22yourDrive%3A%5CYourFolder%5CYourSubFolder%E2%80%A6%E2%80%A6%5CSystem.Net.trace.log%22%20%3C%2FEM%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CEM%3E%20%20%3CBR%20%2F%3E%3CCONFIGURATION%3E%20%3CBR%20%2F%3E%3CSYSTEM.DIAGNOSTICS%3E%20%3CBR%20%2F%3E%3CTRACE%20autoflush%3D%22%26quot%3Btrue%26quot%3B%22%3E%3C%2FTRACE%3E%20%3CBR%20%2F%3E%3CSOURCES%3E%20%3CBR%20%2F%3E%3CSOURCE%20name%3D%22%26quot%3BSystem.Net%26quot%3B%22%3E%20%3CBR%20%2F%3E%3CLISTENERS%3E%20%3CBR%20%2F%3E%3CADD%20name%3D%22%26quot%3BSystem.Net%26quot%3B%2F%22%3E%20%3CBR%20%2F%3E%3C%2FADD%3E%20%3CBR%20%2F%3E%3C%2FLISTENERS%3E%20%3CBR%20%2F%3E%3CSOURCE%20name%3D%22%26quot%3BSystem.Net.HttpListener%26quot%3B%22%3E%20%3CBR%20%2F%3E%3CLISTENERS%3E%20%3CBR%20%2F%3E%3CADD%20name%3D%22%26quot%3BSystem.Net%26quot%3B%2F%22%3E%20%3CBR%20%2F%3E%3C%2FADD%3E%20%3CBR%20%2F%3E%3C%2FLISTENERS%3E%20%3CBR%20%2F%3E%3CSOURCE%20name%3D%22%26quot%3BSystem.Net.Sockets%26quot%3B%22%3E%20%3CBR%20%2F%3E%3CLISTENERS%3E%20%3CBR%20%2F%3E%3CADD%20name%3D%22%26quot%3BSystem.Net%26quot%3B%2F%22%3E%20%3CBR%20%2F%3E%3C%2FADD%3E%20%3CBR%20%2F%3E%3C%2FLISTENERS%3E%20%3CBR%20%2F%3E%3CSOURCE%20name%3D%22%26quot%3BSystem.Net.Cache%26quot%3B%22%3E%20%3CBR%20%2F%3E%3CLISTENERS%3E%20%3CBR%20%2F%3E%3CADD%20name%3D%22%26quot%3BSystem.Net%26quot%3B%2F%22%3E%20%3CBR%20%2F%3E%3C%2FADD%3E%20%3CBR%20%2F%3E%3C%2FLISTENERS%3E%20%3CBR%20%2F%3E%3C%2FSOURCE%3E%20%3CBR%20%2F%3E%3CSHAREDLISTENERS%3E%20%3CBR%20%2F%3E%3CADD%3E%3CBR%20%2F%3Ename%3D%22System.Net%22%20%3CBR%20%2F%3Etype%3D%22System.Diagnostics.TextWriterTraceListener%22%20%3CBR%20%2F%3EinitializeData%3D%22c%3A%5Ctraces%5CSystem.Net.trace.log%22%20%3CBR%20%2F%3EtraceOutputOptions%3D%22DateTime%22%20%3CBR%20%2F%3E%2F%26gt%3B%20%3CBR%20%2F%3E%3C%2FADD%3E%20%3CBR%20%2F%3E%3CSWITCHES%3E%20%3CBR%20%2F%3E%3CADD%20name%3D%22%26quot%3BSystem.Net%26quot%3B%22%20value%3D%22%26quot%3BVerbose%26quot%3B%22%3E%3C%2FADD%3E%20%3CBR%20%2F%3E%3CADD%20name%3D%22%26quot%3BSystem.Net.Sockets%26quot%3B%22%20value%3D%22%26quot%3BVerbose%26quot%3B%22%3E%3C%2FADD%3E%20%3CBR%20%2F%3E%3CADD%20name%3D%22%26quot%3BSystem.Net.Cache%26quot%3B%22%20value%3D%22%26quot%3BVerbose%26quot%3B%22%3E%3C%2FADD%3E%20%3CBR%20%2F%3E%3CADD%20name%3D%22%26quot%3BSystem.Net.HttpListener%26quot%3B%22%20value%3D%22%26quot%3BVerbose%26quot%3B%22%3E%3C%2FADD%3E%20%3CBR%20%2F%3E%3C%2FSWITCHES%3E%20%3CBR%20%2F%3E%3C%2FSHAREDLISTENERS%3E%20%3CBR%20%2F%3E%3C%2FSOURCE%3E%20%3C%2FSOURCE%3E%3C%2FSOURCE%3E%3C%2FSOURCES%3E%3C%2FSYSTEM.DIAGNOSTICS%3E%3C%2FCONFIGURATION%3E%3C%2FEM%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAdditional%20information%20on%20taking%20System.Net%20trace%2C%20please%20check%20%3CA%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fty48b824.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fty48b824.aspx%20%3C%2FA%3Eand%20%3CA%20href%3D%22http%3A%2F%2Fblogs.msdn.com%2Fb%2Fjpsanders%2Farchive%2F2009%2F03%2F24%2Fmy-favorite-system-net-trace-configuration-file-dumps-process-id-and-date-time-information.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fblogs.msdn.com%2Fb%2Fjpsanders%2Farchive%2F2009%2F03%2F24%2Fmy-favorite-system-net-trace-configuration-file-dumps-process-id-and-date-time-information.aspx%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EStep%202%3A%20Review%20System.Net%20trace.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESSL%20connection%20always%20starts%20with%20a%20client%20hello%20payload.%20In%20the%20System.Net%20trace%2C%20you%20will%20see%20something%20like%20this%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5712%5D%20Data%20from%20Socket%2333420276%3A%3ASend%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5712%5D%2000000000%20%3A%2016%2003%2001%2000%206B%2001%2000%2000-67%2003%2001%204F%208A%200F%2082%20CB%20%3A%20....k...g..O....%20%3CBR%20%2F%3E%20System.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5712%5D%2000000010%20%3A%20FD%2008%206F%206C%206F%20DC%20AD%2020-D2%2002%2013%204F%20D8%20F0%20AD%20D9%20%3A%20..olo..%20...O....%20%3CBR%20%2F%3E%20System.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5712%5D%2000000020%20%3A%205C%2022%203C%2063%20C6%2053%20AE%20B2-3D%2021%2081%2000%2000%2018%20C0%2014%20%3A%20%5C%22%3CC.S..%3E%3C%2FC.S..%3E%20System.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5712%5D%2000000030%20%3A%20C0%2013%2000%202F%2000%2035%2000%2005-00%200A%20C0%2009%20C0%200A%2000%2032%20%3A%20...%2F.5.........2%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5712%5D%2000000040%20%3A%2000%2038%2000%2013%2000%2004%2001%2000-00%2026%20FF%2001%2000%2001%2000%2000%20%3A%20.8.......%26amp%3B......%20%3CBR%20%2F%3E%20System.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5712%5D%2000000050%20%3A%2000%2000%200B%2000%2009%2000%2000%2006-68%207A%2064%2073%206B%2038%2000%200A%20%3A%20........hzdsk8..%20%3CBR%20%2F%3E%20System.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5712%5D%2000000060%20%3A%2000%2008%2000%2006%2000%2019%2000%2018-00%2017%2000%200B%2000%2002%2001%2000%20%3A%20................%20%3CBR%20%2F%3E%20System.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5712%5D%20Exiting%20Socket%2333420276%3A%3ASend()%20%26nbsp%3B-%26gt%3B%20112%23112%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E16%26nbsp%3B%20---%20%26gt%3B%20decimal%2022%2C%20means%26nbsp%3Bhandshake(22)%2C%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E03%2001%20---%20%26gt%3B%20SSL%20version%203.1%2C%20so%20it%20is%20TLS%201.0%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E00%206B%20--%20%26gt%3B%20payload%20size%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ETo%20possibly%26nbsp%3Bdetect%20some%20certain%20SSL%20connection%20failure%20from%20text%20based%20System.Net%20log%2C%20now%20we%20can%20leverage%20RFC%202246%2C%20%3CBR%20%2F%3E%3CA%20href%3D%22http%3A%2F%2Fwww.ietf.org%2Frfc%2Frfc2246.txt%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.ietf.org%2Frfc%2Frfc2246.txt%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E7.2.%26nbsp%3B%26nbsp%3B%20Alert%20protocol%3C%2FP%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3EThe%20Raw%20Bytes%20Pattern%20is%26nbsp%3B%2015%2003%2001%2000%2002%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3Elike%20this%20trace%20file%20sample%3A%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%2000000000%20%3A%2015%2003%2001%2000%2002%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E15%3A%20---%20%26gt%3B%20Hex%2C%20means%2021%2C%20it%20is%20a%20signature%20for%20alert%20in%20RFC%202246%2C%20alert(21)%2C%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3Eenum%20%7B%20%3CBR%20%2F%3Echange_cipher_spec(20)%2C%20alert(21)%2C%20handshake(22)%2C%20%3CBR%20%2F%3Eapplication_data(23)%2C%20(255)%20%3CBR%20%2F%3E%7D%20ContentType%3B%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E03%200x%26nbsp%3B%20---%20%26gt%3B%20SSL%20version%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E03%2001%20means%20SSL%20V%203.1%2C%20which%20is%20TLS%201.0%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E03%2000%20means%20SSL%20V%203.0%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E00%2002%20---%20%26gt%3B%20Content%20Size%3A%20which%20is%202%20bytes%3A%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3EThe%20format%20is%20following%20RFC%202246%20SSL%20struct%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3Estruct%20%7B%20%3CBR%20%2F%3EContentType%20type%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20---%26nbsp%3B%20%26gt%3B%201%20byte%20%3CBR%20%2F%3EProtocolVersion%20version%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20---%20%26gt%3B%202%20bytes%20%3CBR%20%2F%3Euint16%20length%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20---%20%26gt%3B%202%20bytes%20%3CBR%20%2F%3Eopaque%20fragment%5BTLSPlaintext.length%5D%3B%20%3CBR%20%2F%3E%7D%20TLSPlaintext%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3ENow%20we%20can%20look%20at%20the%20data%20for%202%20bytes%20Content%3A%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3Etrace%20file%3A%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%2000000005%20%3A%2002%2030%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%20Exiting%20%3CBR%20%2F%3ESocket%2337472519%3A%3AReceive()%20-%26gt%3B%202%232%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E02%20means%3A%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3Eenum%20%7B%20warning(1)%2C%20fatal(2)%2C%20(255)%20%7D%20AlertLevel%3B%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E30%20means%3A%200x30%20---%20%26gt%3B%200n48%2C%20which%20is%20%3CBR%20%2F%3Eunknow_ca%20(the%20issuer%20of%20certificate%20authority%20is%20not%20trusted).%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3EHere%20is%20the%20entire%20enum%20list%20of%20error%20code%26nbsp%3Bfrom%20%3CA%20href%3D%22http%3A%2F%2Fwww.ietf.org%2Frfc%2Frfc2246.txt%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.ietf.org%2Frfc%2Frfc2246.txt%3C%2FA%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3Eenum%20%7B%20%3CBR%20%2F%3Eclose_notify(0)%2C%20%3CBR%20%2F%3Eunexpected_message(10)%2C%20%3CBR%20%2F%3Ebad_record_mac(20)%2C%20%3CBR%20%2F%3Edecryption_failed(21)%2C%20%3CBR%20%2F%3Erecord_overflow(22)%2C%20%3CBR%20%2F%3Edecompression_failure(30)%2C%20%3CBR%20%2F%3Ehandshake_failure(40)%2C%20%3CBR%20%2F%3Ebad_certificate(42)%2C%20%3CBR%20%2F%3Eunsupported_certificate(43)%2C%20%3CBR%20%2F%3Ecertificate_revoked(44)%2C%20%3CBR%20%2F%3Ecertificate_expired(45)%2C%20%3CBR%20%2F%3Ecertificate_unknown(46)%2C%20%3CBR%20%2F%3Eillegal_parameter(47)%2C%20%3CBR%20%2F%3Eunknown_ca(48)%2C%20%3CBR%20%2F%3Eaccess_denied(49)%2C%20%3CBR%20%2F%3Edecode_error(50)%2C%20%3CBR%20%2F%3Edecrypt_error(51)%2C%20%3CBR%20%2F%3Eexport_restriction(60)%2C%20%3CBR%20%2F%3Eprotocol_version(70)%2C%20%3CBR%20%2F%3Einsufficient_security(71)%2C%20%3CBR%20%2F%3Einternal_error(80)%2C%20%3CBR%20%2F%3Euser_canceled(90)%2C%20%3CBR%20%2F%3Eno_renegotiation(100)%2C%20%3CBR%20%2F%3E(255)%20%3CBR%20%2F%3E%7D%20AlertDescription%3B%3C%2FDIV%3E%3CBR%20%2F%3E%3CP%3EHere%20is%20the%20sample%20snippet%20for%20raw%20trace%20file%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%E2%80%A6%20%E2%80%A6.%20%3CBR%20%2F%3E%20System.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%20Socket%2337472519%3A%3AReceive()%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%20Data%20from%20Socket%2337472519%3A%3AReceive%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%2000000000%20%3A%2015%2003%2001%2000%2002%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3A%20.....%20%3CBR%20%2F%3E%20DateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%20Exiting%20Socket%2337472519%3A%3AReceive()%20-%26gt%3B%205%235%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%20Socket%2337472519%3A%3AReceive()%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%20Data%20from%20Socket%2337472519%3A%3AReceive%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%2000000005%20%3A%2002%2030%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3A%20.0%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%20Exiting%20Socket%2337472519%3A%3AReceive()%20-%26gt%3B%202%232%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net%20Information%3A%200%20%3A%20%5B5792%5D%20InitializeSecurityContext(credential%20%3D%20System.Net.SafeFreeCredential_SECURITY%2C%20context%20%3D%20225480%3A1107220%2C%20targetName%20%3D%20gmservices.pp.gm.com%2C%20inFlags%20%3D%20ReplayDetect%2C%20SequenceDetect%2C%20Confidentiality%2C%20AllocateMemory%2C%20InitManualCredValidation)%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1341615Z%20%3CBR%20%2F%3ESystem.Net%20Information%3A%200%20%3A%20%5B5792%5D%20InitializeSecurityContext(In-Buffers%20count%3D2%2C%20Out-Buffer%20length%3D0%2C%20returned%20code%3DUntrustedRoot).%20%3CBR%20%2F%3E%20DateTime%3D2009-07-09T19%3A13%3A26.1497868Z%20%3CBR%20%2F%3ESystem.Net.Sockets%20Verbose%3A%200%20%3A%20%5B5792%5D%20Socket%2337472519%3A%3ADispose()%20%3CBR%20%2F%3EDateTime%3D2009-07-09T19%3A13%3A26.1654121Z%20%3CBR%20%2F%3ESystem.Net%20Error%3A%200%20%3A%20%5B5792%5D%20Exception%20in%20the%20HttpWebRequest%2355855606%3A%3A%20-%20The%20request%20was%20aborted%3A%20Could%20not%20create%20SSL%2FTLS%20secure%20channel.%20%3CBR%20%2F%3E%20DateTime%3D2009-07-09T19%3A13%3A26.1654121Z%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-287709%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Nov%2005%2C%202012%20WCF%20client%20and%20ASMX%20webservice%20client%20all%20use%20the%20System.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-287709%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Ehttpwebrequest%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Esystem%20net%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on MSDN on Nov 05, 2012

WCF client and ASMX webservice client all use the System.Net.HttpWebRequest object to create underlying SSL connection. If you experience any SSL related problem, you can take a System.Net trace first.


If System.Net trace shows the pattern of following SSL alert sequence 15 03 01 00 02, we can use RFC 2246, http://www.ietf.org/rfc/rfc2246.txt , section 7.2 to get the possible root cause of SSL failure.


Sample snippet in System.Net trace.


System.Ne.Sockets Verbose: 0 : [5136] 00000000 : 15 03 01 00 02 :



Step 1: Taking System.Net trace.


1.)    Add the contents of the listed XML file to your application configuration file.


If you have a desktop application, the configuration file will be a file called YourApp.exe.config
If it is an asp.net application, the configuration file will be a file called web.config residing in your asp.net application directory.


2.)    Please create a folder called c:\traces, and give full permissions to “Everyone”. This will ensure that the log will get created regardless of the process/thread identity.


3.)    Restart your application process (YourApp.exe for desktop applications and w3wp.exe for asp.net applications)


4.)    Reproduce the problem


5.)    You should see a file called System.Net.trace.log in the c:\traces folder.


Note: If you want to change the location of where the log gets generated, you can do it by changing the following section:


initializeData="yourDrive:\YourFolder\YourSubFolder……\System.Net.trace.log"


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.HttpListener">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Cache">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add
name="System.Net"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="c:\traces\System.Net.trace.log"
traceOutputOptions="DateTime"
/>
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
<add name="System.Net.Cache" value="Verbose" />
<add name="System.Net.HttpListener" value="Verbose" />
</switches>
</system.diagnostics>
</configuration>


Additional information on taking System.Net trace, please check http://msdn.microsoft.com/en-us/library/ty48b824.aspx and http://blogs.msdn.com/b/jpsanders/archive/2009/03/24/my-favorite-system-net-trace-configuration...


Step 2: Review System.Net trace.


SSL connection always starts with a client hello payload. In the System.Net trace, you will see something like this:


System.Net.Sockets Verbose: 0 : [5712] Data from Socket#33420276::Send
System.Net.Sockets Verbose: 0 : [5712] 00000000 : 16 03 01 00 6B 01 00 00-67 03 01 4F 8A 0F 82 CB : ....k...g..O....
System.Net.Sockets Verbose: 0 : [5712] 00000010 : FD 08 6F 6C 6F DC AD 20-D2 02 13 4F D8 F0 AD D9 : ..olo.. ...O....
System.Net.Sockets Verbose: 0 : [5712] 00000020 : 5C 22 3C 63 C6 53 AE B2-3D 21 81 00 00 18 C0 14 : \"<c.S..=!......
System.Net.Sockets Verbose: 0 : [5712] 00000030 : C0 13 00 2F 00 35 00 05-00 0A C0 09 C0 0A 00 32 : .../.5.........2
System.Net.Sockets Verbose: 0 : [5712] 00000040 : 00 38 00 13 00 04 01 00-00 26 FF 01 00 01 00 00 : .8.......&......
System.Net.Sockets Verbose: 0 : [5712] 00000050 : 00 00 0B 00 09 00 00 06-68 7A 64 73 6B 38 00 0A : ........hzdsk8..
System.Net.Sockets Verbose: 0 : [5712] 00000060 : 00 08 00 06 00 19 00 18-00 17 00 0B 00 02 01 00 : ................
System.Net.Sockets Verbose: 0 : [5712] Exiting Socket#33420276::Send()  -> 112#112


16  --- > decimal 22, means handshake(22),


03 01 --- > SSL version 3.1, so it is TLS 1.0


00 6B -- > payload size


To possibly detect some certain SSL connection failure from text based System.Net log, now we can leverage RFC 2246,
http://www.ietf.org/rfc/rfc2246.txt


7.2.   Alert protocol



The Raw Bytes Pattern is  15 03 01 00 02

like this trace file sample:

System.Net.Sockets Verbose: 0 : [5792] 00000000 : 15 03 01 00 02


15: --- > Hex, means 21, it is a signature for alert in RFC 2246, alert(21),


enum {
change_cipher_spec(20), alert(21), handshake(22),
application_data(23), (255)
} ContentType;


03 0x  --- > SSL version

03 01 means SSL V 3.1, which is TLS 1.0

03 00 means SSL V 3.0


00 02 --- > Content Size: which is 2 bytes:


The format is following RFC 2246 SSL struct

struct {
ContentType type;                 ---  > 1 byte
ProtocolVersion version;        --- > 2 bytes
uint16 length;                         --- > 2 bytes
opaque fragment[TLSPlaintext.length];
} TLSPlaintext;

Now we can look at the data for 2 bytes Content:


trace file:

System.Net.Sockets Verbose: 0 : [5792] 00000005 : 02 30

DateTime=2009-07-09T19:13:26.1341615Z
System.Net.Sockets Verbose: 0 : [5792] Exiting
Socket#37472519::Receive() -> 2#2
DateTime=2009-07-09T19:13:26.1341615Z



02 means:

enum { warning(1), fatal(2), (255) } AlertLevel;


30 means: 0x30 --- > 0n48, which is
unknow_ca (the issuer of certificate authority is not trusted).



Here is the entire enum list of error code from http://www.ietf.org/rfc/rfc2246.txt


enum {
close_notify(0),
unexpected_message(10),
bad_record_mac(20),
decryption_failed(21),
record_overflow(22),
decompression_failure(30),
handshake_failure(40),
bad_certificate(42),
unsupported_certificate(43),
certificate_revoked(44),
certificate_expired(45),
certificate_unknown(46),
illegal_parameter(47),
unknown_ca(48),
access_denied(49),
decode_error(50),
decrypt_error(51),
export_restriction(60),
protocol_version(70),
insufficient_security(71),
internal_error(80),
user_canceled(90),
no_renegotiation(100),
(255)
} AlertDescription;

Here is the sample snippet for raw trace file:


… ….
System.Net.Sockets Verbose: 0 : [5792] Socket#37472519::Receive()
DateTime=2009-07-09T19:13:26.1341615Z
System.Net.Sockets Verbose: 0 : [5792] Data from Socket#37472519::Receive
DateTime=2009-07-09T19:13:26.1341615Z
System.Net.Sockets Verbose: 0 : [5792] 00000000 : 15 03 01 00 02                                  : .....
DateTime=2009-07-09T19:13:26.1341615Z
System.Net.Sockets Verbose: 0 : [5792] Exiting Socket#37472519::Receive() -> 5#5
DateTime=2009-07-09T19:13:26.1341615Z
System.Net.Sockets Verbose: 0 : [5792] Socket#37472519::Receive()
DateTime=2009-07-09T19:13:26.1341615Z
System.Net.Sockets Verbose: 0 : [5792] Data from Socket#37472519::Receive
DateTime=2009-07-09T19:13:26.1341615Z
System.Net.Sockets Verbose: 0 : [5792] 00000005 : 02 30                                           : .0
DateTime=2009-07-09T19:13:26.1341615Z
System.Net.Sockets Verbose: 0 : [5792] Exiting Socket#37472519::Receive() -> 2#2
DateTime=2009-07-09T19:13:26.1341615Z
System.Net Information: 0 : [5792] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 225480:1107220, targetName = gmservices.pp.gm.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
DateTime=2009-07-09T19:13:26.1341615Z
System.Net Information: 0 : [5792] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=UntrustedRoot).
DateTime=2009-07-09T19:13:26.1497868Z
System.Net.Sockets Verbose: 0 : [5792] Socket#37472519::Dispose()
DateTime=2009-07-09T19:13:26.1654121Z
System.Net Error: 0 : [5792] Exception in the HttpWebRequest#55855606:: - The request was aborted: Could not create SSL/TLS secure channel.
DateTime=2009-07-09T19:13:26.1654121Z