Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

Facebook - ASP.NET/WebClient 사용 시 graph.facebook.com/me 호출에 대해 403 Forbidden 오류

잘 동작하던 Facebook의 Graph API 호출이,

string url = "https://graph.facebook.com/me?fields=email&access_token=" + access_token;
wc = new WebClient();
string text = wc.DownloadString(url); // 예외 발생

어느 순간부터 403 오류가 발생합니다.

System.Net.WebException
  HResult=0x80131509
  Message=The remote server returned an error: (403) Forbidden.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Facebook 개발자 페이지에 들어가 해당 App에 대해 설정을 찾아봐도 별다른 특이점이 없습니다. 그러다, 혹시나 싶어 nuget으로부터 Facebook 패키지를 참조해,

Install-Package Facebook

// Install-Package Facebook -Version 7.0.6

제공하는 코드를 사용했더니,

var client = new FacebookClient(access_token);
dynamic me = client.Get("me");

이런 오류로 바뀝니다.

Facebook.FacebookApiException
  HResult=0x80131500
  Message=(GraphInsecureException - #8) TLS versions older than v1.2 are not supported.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

그러니까, 결국 예전에 설명한 문제가 Facebook의 API 서버 호출에도 발생한 것으로,

C# - WebClient로 https 호출 시 "The request was aborted: Could not create SSL/TLS secure channel" 예외 발생
; https://www.sysnet.pe.kr/2/0/13233

JetBrains Omea Reader에서 TLS 1.2 모드의 https 서버로부터 RSS 구독이 안 되는 경우 해결 방법
; https://www.sysnet.pe.kr/0/0/547

Facebook 측에서 낮은 버전의 TLS 지원을 더 이상 하지 않기로 결정한 것입니다. 따라서 해결책은 Global 타입의 정적 생성자에 Tls12 옵션을 추가해 주면 됩니다. ^^

public class Global : System.Web.HttpApplication
{
    static Global()
    {
        ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
    }

    // ...[생략]...
}

그나저나... 이런 변화들은 다소 심각한 문제로 보입니다. 가령, (이미 외주 개발이 끝난) 예전 ASP.NET으로 만들어진 사이트들의 경우 어느 순간부터는 로그인 오류가 발생해 버리기 때문입니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 5/31/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  [4]  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13711정성태8/13/20243122Linux: 77. C# / Linux - zombie process (defunct process)파일 다운로드1
13710정성태8/8/20243183닷넷: 2294. C# 13 - (6) iterator 또는 비동기 메서드에서 ref와 unsafe 사용을 부분적으로 허용파일 다운로드1
13709정성태8/7/20243051닷넷: 2293. C# - safe/unsafe 문맥에 대한 C# 13의 (하위 호환을 깨는) 변화파일 다운로드1
13708정성태8/7/20242698개발 환경 구성: 719. ffmpeg / YoutubeExplode - mp4 동영상 파일로부터 Audio 파일 추출
13707정성태8/6/20243118닷넷: 2292. C# - 자식 프로세스의 출력이 4,096보다 많은 경우 Process.WaitForExit 호출 시 hang 현상파일 다운로드1
13706정성태8/5/20243167개발 환경 구성: 718. Hyper-V - 리눅스 VM에 새로운 디스크 추가
13705정성태8/4/20243515닷넷: 2291. C# 13 - (5) params 인자 타입으로 컬렉션 허용파일 다운로드1
13704정성태8/2/20243294닷넷: 2290. C# - 간이 dotnet-dump 프로그램 만들기파일 다운로드1
13703정성태8/1/20243455닷넷: 2289. "dotnet-dump ps" 명령어가 닷넷 프로세스를 찾는 방법
13702정성태7/31/20243320닷넷: 2288. Collection 식을 지원하는 사용자 정의 타입을 CollectionBuilder 특성으로 성능 보완파일 다운로드1
13701정성태7/30/20243312닷넷: 2287. C# 13 - (4) Indexer를 이용한 개체 초기화 구문에서 System.Index 연산자 허용파일 다운로드1
13700정성태7/29/20243004디버깅 기술: 200. DLL Export/Import의 Hint 의미
13699정성태7/27/20243143닷넷: 2286. C# 13 - (3) Monitor를 대체할 Lock 타입파일 다운로드1
13698정성태7/27/20243064닷넷: 2285. C# - async 메서드에서의 System.Threading.Lock 잠금 처리파일 다운로드1
13697정성태7/26/20243238닷넷: 2284. C# - async 메서드에서의 lock/Monitor.Enter/Exit 잠금 처리파일 다운로드1
13696정성태7/26/20243132오류 유형: 920. dotnet publish - error NETSDK1047: Assets file '...\obj\project.assets.json' doesn't have a target for '...'
13695정성태7/25/20242814닷넷: 2283. C# - Lock / Wait 상태에서도 STA COM 메서드 호출 처리파일 다운로드1
13694정성태7/25/20243070닷넷: 2282. C# - ASP.NET Core Web App의 Request 용량 상한값 (Kestrel, IIS)
13693정성태7/24/20242956개발 환경 구성: 717. Visual Studio - C# 프로젝트에서 레지스트리에 등록하지 않은 COM 개체 참조 및 사용 방법파일 다운로드1
13692정성태7/24/20243522디버깅 기술: 199. Windbg - 리눅스에서 뜬 닷넷 응용 프로그램 덤프 파일에 포함된 DLL의 Export Directory 탐색
13691정성태7/23/20243022디버깅 기술: 198. Windbg - 스레드의 Win32 Message Queue 정보 조회
13690정성태7/23/20242760오류 유형: 919. Visual C++ 리눅스 프로젝트 - error : ‘u8’ was not declared in this scope
13689정성태7/22/20243228디버깅 기술: 197. Windbg - PE 포맷의 Export Directory 탐색
13688정성태7/21/20243065닷넷: 2281. C# - Lock / Wait 상태에서도 일부 Win32 메시지 처리파일 다운로드1
13687정성태7/19/20243303닷넷: 2280. C# - PostThreadMessage로 보낸 메시지를 Windows Forms에서 수신하는 방법파일 다운로드1
13686정성태7/19/20243360오류 유형: 918. Visual Studio - ATL Simple Object 추가 시 error C2065: 'IDR_...': undeclared identifier
1  2  3  [4]  5  6  7  8  9  10  11  12  13  14  15  ...