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)
13753정성태10/4/20243615Linux: 81. Linux - PATH 환경변수의 적용 규칙
13752정성태10/2/20243897닷넷: 2303. C# 13 - (7) ref struct의 interface 상속 및 제네릭 제약으로 사용 가능파일 다운로드1
13751정성태10/2/20243471C/C++: 176. C/C++ - ARM64로 포팅할 때 유의할 점
13750정성태10/1/20243390C/C++: 175. C++ - WinMain/wWinMain 호출 전의 CRT 초기화 단계
13749정성태9/30/20243565닷넷: 2302. C# - ssh-keygen으로 생성한 Private Key와 Public Key 연동파일 다운로드1
13748정성태9/29/20243540닷넷: 2301. C# - BigInteger 타입이 byte 배열로 직렬화하는 방식
13747정성태9/28/20243232닷넷: 2300. C# - OpenSSH의 공개키 파일에 대한 "BEGIN OPENSSH PUBLIC KEY" / "END OPENSSH PUBLIC KEY" PEM 포맷파일 다운로드1
13746정성태9/28/20243301오류 유형: 924. Python - LocalProtocolError("Illegal header value ...")
13745정성태9/28/20243365Linux: 80. 리눅스 - 실행 중인 프로세스 내부의 환경변수 설정을 구하는 방법 (lldb)
13744정성태9/27/20244020닷넷: 2299. C# - Windows Hello 사용자 인증 다이얼로그 표시하기파일 다운로드1
13743정성태9/26/20244030닷넷: 2298. C# - Console 프로젝트에서의 await 대상으로 Main 스레드 활용하는 방법 [1]
13742정성태9/26/20244550닷넷: 2297. C# - ssh-keygen으로 생성한 ecdsa 유형의 Public Key 파일 해석 [1]파일 다운로드1
13741정성태9/25/20243861디버깅 기술: 202. windbg - ASP.NET MVC Web Application (.NET Framework) 응용 프로그램의 덤프 분석 시 요령
13740정성태9/24/20243851기타: 86. RSA 공개키 등의 modulus 값에 0x00 선행 바이트가 있는 이유(ASN.1 인코딩)
13739정성태9/24/20243913닷넷: 2297. C# - ssh-keygen으로 생성한 Public Key 파일 해석과 fingerprint 값(md5, sha256) 생성 [1]파일 다운로드1
13738정성태9/22/20243539C/C++: 174. C/C++ - 윈도우 운영체제에서의 file descriptor, FILE*파일 다운로드1
13737정성태9/21/20244175개발 환경 구성: 727. Visual C++ - 리눅스 프로젝트를 위한 빌드 서버의 msbuild 구성
13736정성태9/20/20243784오류 유형: 923. Visual Studio Code - Could not establish connection to "...": Port forwarding is disabled.
13735정성태9/20/20244144개발 환경 구성: 726. ARM 플랫폼용 Visual C++ 리눅스 프로젝트 빌드
13734정성태9/19/20243996개발 환경 구성: 725. ssh를 이용한 원격 docker 서비스 사용
13733정성태9/19/20244011VS.NET IDE: 194. Visual Studio - Cross Platform / "Authentication Type: Private Key"로 접속하는 방법
13732정성태9/17/20244017개발 환경 구성: 724. ARM + docker 환경에서 .NET 8 설치
13731정성태9/15/20244660개발 환경 구성: 723. C# / Visual C++ - Control Flow Guard (CFG) 활성화 [1]파일 다운로드2
13730정성태9/10/20244016오류 유형: 922. docker - RULE_APPEND failed (No such file or directory): rule in chain DOCKER
13729정성태9/9/20244682C/C++: 173. Windows / C++ - AllocConsole로 할당한 콘솔과 CRT 함수 연동 [1]파일 다운로드1
13728정성태9/7/20244398C/C++: 172. Windows - C 런타임에서 STARTUPINFO의 cbReserved2, lpReserved2 멤버를 사용하는 이유파일 다운로드1
1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...