{"id":1546,"date":"2018-08-04T01:02:29","date_gmt":"2018-08-03T22:02:29","guid":{"rendered":"http:\/\/guvensahin.com\/?p=1546"},"modified":"2020-05-12T23:57:26","modified_gmt":"2020-05-12T20:57:26","slug":"dynamics-ax-sadece-tls-1-2-destekleyen-web-servislerin-kullanimi","status":"publish","type":"post","link":"https:\/\/guvensahin.com\/tr\/dynamics-ax-sadece-tls-1-2-destekleyen-web-servislerin-kullanimi\/","title":{"rendered":"Dynamics AX 2009\/2012: Sadece TLS 1.2 Destekleyen Web Servislerin Kullan\u0131m\u0131"},"content":{"rendered":"<p>Bu yaz\u0131da hem ax 2009 hemde ax 2012 de <a href=\"https:\/\/www.wikiwand.com\/tr\/Transport_Layer_Security\">TLS<\/a> 1.2 gibi g\u00fcncel g\u00fcvenlik protokol\u00fcn\u00fc destekleyen web servislere nas\u0131l eri\u015febilece\u011fimizden bahsedece\u011fim. Bir sunucu sadece TLS 1.2 destekliyorsa ax i\u00e7inden bir istek g\u00f6nderdi\u011finizde a\u015fa\u011f\u0131daki hata ile kar\u015f\u0131la\u015f\u0131rs\u0131n\u0131z.<\/p>\n<p><strong><em>The underlying connection was closed: An unexpected error occurred on a send. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. An existing connection was forcibly closed by the remote host.<\/em><\/strong><\/p>\n<p>TLS 1.0 protokol\u00fcn\u00fcn a\u00e7\u0131klar\u0131 oldu\u011fu i\u00e7in baz\u0131 sunucular direkt olarak bloklamakta. Bu hatay\u0131 giderebilmek i\u00e7in, ax i\u00e7inden sunucuya istekte bulunurken g\u00fcvenlik protokol\u00fcn\u00fc sunucunun destekledi\u011fi TLS s\u00fcr\u00fcm\u00fc olarak ayarlamak gerekiyor. Buda genellikle 1.1 yada 1.2 olmakta.<\/p>\n<p>&nbsp;<\/p>\n<h2>Bir Sitenin Destekledi\u011fi TLS Versiyonunu \u00d6\u011frenme<\/h2>\n<p>Bir sitenin hangi g\u00fcvenlik protokollerini destekledi\u011fini g\u00f6rmek i\u00e7in bu adresteki <a href=\"https:\/\/www.ssllabs.com\/ssltest\"><strong>servisi kullanabilirsiniz<\/strong><\/a>.<\/p>\n<p>\u00d6rne\u011fin:<\/p>\n<p><a href=\"https:\/\/www.google.com\/\"><strong>google.com<\/strong><\/a> &#8211; t\u00fcm TLS s\u00fcr\u00fcmlerini <a href=\"https:\/\/www.ssllabs.com\/ssltest\/analyze.html?d=google.com&amp;s=216.58.194.174\"><strong>destekliyor<\/strong><\/a>.<\/p>\n<p><a href=\"https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_google_com.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1554\" src=\"https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_google_com.png\" alt=\"\" width=\"1102\" height=\"422\" srcset=\"https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_google_com.png 1102w, https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_google_com-300x115.png 300w, https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_google_com-768x294.png 768w, https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_google_com-1024x392.png 1024w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong><a href=\"https:\/\/www.incapsula.com\/\">incapsula.com<\/a><\/strong> &#8211; sadece TLS 1.2 <a href=\"https:\/\/www.ssllabs.com\/ssltest\/analyze.html?d=www.incapsula.com&amp;s=2a02%3ae980%3a57%3a0%3a0%3a0%3a0%3a29&amp;latest\"><strong>destekliyor<\/strong><\/a>.<\/p>\n<p><a href=\"https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_incapsula_com.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1557\" src=\"https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_incapsula_com.png\" alt=\"\" width=\"1095\" height=\"296\" srcset=\"https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_incapsula_com.png 1095w, https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_incapsula_com-300x81.png 300w, https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_incapsula_com-768x208.png 768w, https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ssltest_incapsula_com-1024x277.png 1024w\" sizes=\"auto, (max-width: 1095px) 100vw, 1095px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Bu sorunu giderebilmek i\u00e7in ax s\u00fcr\u00fcmlerine g\u00f6re farkl\u0131 aksiyonlar almam\u0131z gerekiyor. Burada kilit nokta a\u015fa\u011f\u0131daki belirtti\u011fim kod par\u00e7ac\u0131\u011f\u0131. Bu \u00e7al\u0131\u015ft\u0131ktan sonra yap\u0131lacak olan t\u00fcm requestlerde .NET&#8217;in kulland\u0131\u011f\u0131 varsay\u0131lan TLS versiyonunu 1.2 yap\u0131yoruz.<\/p>\n<pre>System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h2>AX 2009 i\u00e7in<\/h2>\n<p>Ax 2009 .NET 3.5 kullan\u0131yor. Ve bu s\u00fcr\u00fcmde sadece SSL 3 ve TLS 1.0 kullanabiliyorsunuz. TLS 1.2 isteyen bir siteye eri\u015fmek yapabilece\u011finiz en iyi y\u00f6ntem .Net 4.0 veya \u00fcst\u00fcn\u00fc kullanan bir asmx web servis yaz\u0131p bunu ax 2009 i\u00e7inde \u00e7a\u011f\u0131rmak olacakt\u0131r. Web servisde ise a\u015fa\u011f\u0131da verdi\u011fim \u00f6rnek kodu kullanabilirsiniz.<\/p>\n<p>\u00d6rnek kod .NET Framework&#8217;\u00fcn en g\u00fcncel y\u00f6ntemi olan <a href=\"https:\/\/docs.microsoft.com\/tr-tr\/aspnet\/web-api\/overview\/advanced\/calling-a-web-api-from-a-net-client\"><strong>HttpClient<\/strong><\/a>&#8216;\u0131 kullan\u0131yor. Bu k\u00fct\u00fcphaneyi kullanabilmek asmx servisin versiyonu .NET Framework 4.5+ olmal\u0131. 4.0 versiyonu i\u00e7in <a href=\"https:\/\/stackoverflow.com\/questions\/4015324\/how-to-make-http-post-web-request\"><strong>bu linkte yer alan<\/strong><\/a> WebRequest vb. legacy y\u00f6ntemler ile sorguyu g\u00fcncelleyebilirsiniz. Burada \u00f6nemli nokta SecurityProtocol atamas\u0131 yapt\u0131\u011f\u0131m\u0131z b\u00f6l\u00fcm\u00fcn aynen kalmas\u0131 gerekiyor.<\/p>\n<p>&nbsp;<\/p>\n<pre>\/\/ G\u00fcven \u015eahin - guvensahin.com\r\npublic HttpResponseMessage GetProductImages()\r\n{\r\n\ttry\r\n\t{\r\n\t\tstring ret = String.Empty;\r\n\t\tstring url = \"\"; \/\/ istek yap\u0131lacak url yaz\u0131lmal\u0131\r\n\r\n\t\tusing (var client = new HttpClient())\r\n\t\t{\r\n\t\t\t\/\/ istek yaparken TLS 1.2'yi varsay\u0131lan g\u00fcvenlik protokol\u00fc olarak at\u0131yoruz\r\n\t\t\tSystem.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;\r\n\r\n\r\n\t\t\tclient.Timeout = new TimeSpan(0, 2, 0); \/\/ 2 min\r\n\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tvar response = client.GetAsync(url).Result;\r\n\r\n\t\t\t\tif (response.IsSuccessStatusCode)\r\n\t\t\t\t{\r\n\t\t\t\t\tret = response.Content.ReadAsStringAsync().Result;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tvar msg = \"url: \" + url + \"\\n\"\r\n\t\t\t\t\t\t+ \"StatusCode: \" + response.StatusCode.ToString() + \"\\n\"\r\n\t\t\t\t\t\t+ \"ReasonPhrase: \" + response.ReasonPhrase;\r\n\t\t\t\t\tthrow new Exception(msg);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tfinally\r\n\t\t\t{\r\n\t\t\t\tclient.Dispose();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn Request.CreateResponse(HttpStatusCode.OK, ret);\r\n\t}\r\n\tcatch (Exception ex)\r\n\t{\r\n\t\treturn Request.CreateResponse(HttpStatusCode.InternalServerError, ex);\r\n\t}\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h2>AX 2012 i\u00e7in<\/h2>\n<p>AX 2012 .NET 4.0 kulland\u0131\u011f\u0131 i\u00e7in .NET&#8217;te ge\u00e7erli olan SecurityProtocol komutunu direkt ax i\u00e7inden \u00e7a\u011f\u0131rabiliyoruz. A\u015fa\u011f\u0131daki \u00f6rnek job&#8217;\u0131 kullanarak TLS 1.2 destekli bir siteye direkt istekte bulunabilirsiniz. SecurityProtocol atamas\u0131 yapan k\u0131sm\u0131 commentleyip denerseniz TLS 1.0&#8217;a d\u00f6nece\u011fi i\u00e7in yaz\u0131n\u0131n ba\u015f\u0131nda belirtti\u011fim hatay\u0131 alacaks\u0131n\u0131z.<\/p>\n<pre>\/\/ G\u00fcven \u015eahin - guvensahin.com\r\nstatic void GVNWebClientTestTLS12(Args _args)\r\n{\r\n    System.Net.WebClient    webClient;\r\n    str                     content;\r\n    ;\r\n\r\n    new InteropPermission(InteropKind::CLRInterop).assert();\r\n\r\n    try\r\n    {\r\n        System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);\r\n        \r\n        webClient   = new System.Net.WebClient();\r\n        content     = @webClient.DownloadString(\"https:\/\/www.incapsula.com\/\");\r\n        \r\n        info(content);\r\n    }\r\n    catch (Exception::CLRError)\r\n    {\r\n        throw error(AifUtil::getClrErrorMessage());\r\n    }\r\n\r\n    CodeAccessPermission::revertAssert();\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ax2012_web_client_tls12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1559\" src=\"https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ax2012_web_client_tls12.png\" alt=\"\" width=\"1200\" height=\"420\" srcset=\"https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ax2012_web_client_tls12.png 1200w, https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ax2012_web_client_tls12-300x105.png 300w, https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ax2012_web_client_tls12-768x269.png 768w, https:\/\/guvensahin.com\/tr\/wp-content\/uploads\/2018\/08\/ax2012_web_client_tls12-1024x358.png 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Sonraki yaz\u0131larda g\u00f6r\u00fc\u015fmek \u00fczere,<br \/>\nHo\u015f\u00e7akal\u0131n.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bu yaz\u0131da hem ax 2009 hemde ax 2012 de TLS 1.2 gibi g\u00fcncel g\u00fcvenlik protokol\u00fcn\u00fc destekleyen web servislere nas\u0131l eri\u015febilece\u011fimizden bahsedece\u011fim. Bir sunucu sadece TLS 1.2 destekliyorsa ax i\u00e7inden bir istek g\u00f6nderdi\u011finizde a\u015fa\u011f\u0131daki hata ile kar\u015f\u0131la\u015f\u0131rs\u0131n\u0131z. The underlying connection was closed: An unexpected error occurred on a send. Unable to read data from the transport&hellip;&nbsp;<a href=\"https:\/\/guvensahin.com\/tr\/dynamics-ax-sadece-tls-1-2-destekleyen-web-servislerin-kullanimi\/\" rel=\"bookmark\">Daha fazlas\u0131n\u0131 oku &raquo;<span class=\"screen-reader-text\">Dynamics AX 2009\/2012: Sadece TLS 1.2 Destekleyen Web Servislerin Kullan\u0131m\u0131<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1569,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[234],"tags":[432,193,198,415,285],"class_list":["post-1546","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-ax","tag-net","tag-axapta","tag-dynamics-ax-2","tag-web-service","tag-x"],"_links":{"self":[{"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/posts\/1546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/comments?post=1546"}],"version-history":[{"count":17,"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/posts\/1546\/revisions"}],"predecessor-version":[{"id":1570,"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/posts\/1546\/revisions\/1570"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/media\/1569"}],"wp:attachment":[{"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/media?parent=1546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/categories?post=1546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guvensahin.com\/tr\/wp-json\/wp\/v2\/tags?post=1546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}