SlideShare a Scribd company logo
Client Certificate validation
in Windows 8/8.1 winRT app
-Ashish Agrawal
Problem Statement
• How to do certificate validation in windows RT metro app.
Binary Security Based token authentication
• <wsse:BinarySecurityToken
Id="Compact0">ABCD</wsse:BinarySecurityToken>
• In non encrypted token response, we directly get the binary Security
token from where we can get the RTFA and FEDAuth cookies and
communicate with the server.
• https://login.partner.microsoftonline.cn should be hit to get the
encrypted token
Encrypted token
• <wst:RequestedSecurityToken>
• <EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Id="Assertion0" Type="http://www.w3.org/2001/04/xmlenc#Element">
• <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"></EncryptionMethod>
• <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
• <EncryptedKey>
• <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"></EncryptionMethod>
• <ds:KeyInfo>
• <ds:X509Data>
• <ds:X509SKI>ac4GbK23Iw/V29Ef4tJAaZwrR6I=</ds:X509SKI>
• </ds:X509Data>
• <ds:KeyName>sharepoint.cn</ds:KeyName>
• </ds:KeyInfo>
• <CipherData>
• <CipherValue>ABCD</CipherValue>
• </CipherData>
• </EncryptedKey>
• </ds:KeyInfo>
•
• <CipherData>
• <CipherValue>XXX/CipherData>
• </EncryptedData>
• </wst:RequestedSecurityToken>
• <wst:RequestedAttachedReference>
• <wsse:SecurityTokenReference>
• <wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID">uuid-
e36c6939-c283-4c68-ad2e-8e5720b9c51a</wsse:KeyIdentifier>
• </wsse:SecurityTokenReference>
• </wst:RequestedAttachedReference>
• <wst:RequestedUnattachedReference>
• <wsse:SecurityTokenReference>
• <wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID">uuid-
e36c6939-c283-4c68-ad2e-8e5720b9c51a</wsse:KeyIdentifier>
• </wsse:SecurityTokenReference>
• </wst:RequestedUnattachedReference>
• <wst:RequestedProofToken>
• <wst:BinarySecret>8TM1ybkRA1Y4QURgKaIlzu7gywlQscqI</wst:BinarySecret>
• </wst:RequestedProofToken>
• </wst:RequestSecurityTokenResponse>
Encrypted token cont..
The data encryption process can be
understood from below link:
• http://msdn.microsoft.com/en-
us/library/vstudio/aa967562(v=vs.90).aspx
How to get locally installed certificate in
WinRTapp
• In-order to access locally installed X509 certificated, the below
capability need to be enabled in app manifest
• <Capabilities>
• <Capability Name="internetClient" />
• <Capability Name="sharedUserCertificates" />
• </Capabilities>
Code to access local certificate
• use Windows.Security
(System.Security namespace is unavailable in winRT apps)
• Windows.Security.Cryptography.Certificates.CertificateQuery cq =
new Windows.Security.Cryptography.Certificates.CertificateQuery();
cq.Thumbprint = data;
(Create certificate query using the thumbprint received from
encrypted token xml. ds:X509SKI)
• IEnumerable<Certificate> certificates = await
CertificateStores.FindAllAsync(cq);
(Using the certificate query we can access all the local certificates)
How to get Rtfa and FedAuth cookie
• Once we get the desired certificate based on the certificate query, we
should get its private key and use it to decrypt the cipher data:
• <CipherData>
• <CipherValue>ABCD</CipherValue>
• </CipherData>
• This decrypted key should be used to further decrypt the
RequestedSecurityToken and get the actual cookie (rtfa and fedauth)
Incase required certificate is not present
locally. Certificate enrollment
• Security server specially bank servers provide certificate enrollment
API which provide certificate to be used to validation.
• http://msdn.microsoft.com/en-US/library/windows/apps/hh464943
Create Certificate Request
• Create certificate request properties with the required parameters:
• CertificateRequestProperties reqProperties = new CertificateRequestProperties();
• reqProperties.KeyUsages = EnrollKeyUsages.Signing;
• reqProperties.FriendlyName = "Ashish";
• Make a request using the certificate properties
• String cert = await CertificateEnrollmentManager.CreateRequestAsync(reqProperties);
Get certificate from server for decryption
• string postJsonData = "{"Username":"zhao@saifdemo.partner.onmschina.cn","&Password":"password01!"}";
• var clientHandler = new HttpClientHandler();
• byte[] responsecert = await SpCommon.SendHttpRequest(
new Uri(“SERVERURL"),
HttpMethod.Post,
new MemoryStream(Encoding.UTF8.GetBytes(postJsonData)),
"application/x-www-form-urlencoded",
clientHandler);
• if (responsecert != null)
• {
• // parse the required x509 certificate response
• }
Thanks.
• For any queries Contact me : meetashish@gmail.com

More Related Content

PPTX
Authenticating Angular Apps with JWT
PDF
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
PPTX
Microservice Protection With WSO2 Identity Server
PPTX
JWT SSO Inbound Authenticator
PDF
Protecting web APIs with OAuth 2.0
PDF
ConFoo 2015 - Securing RESTful resources with OAuth2
PDF
FIDO2 Specifications Overview
PDF
Getting Started with Spring Authorization Server
Authenticating Angular Apps with JWT
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
Microservice Protection With WSO2 Identity Server
JWT SSO Inbound Authenticator
Protecting web APIs with OAuth 2.0
ConFoo 2015 - Securing RESTful resources with OAuth2
FIDO2 Specifications Overview
Getting Started with Spring Authorization Server

What's hot (20)

PDF
FIDO2 Specifications Overview
PDF
DEF CON 27 - ALVARO MUNOZ / OLEKSANDR MIROSH - sso wars the token menace
PPTX
Internet banking safeguards vulnerabilities - OWASP AppSec EU 2016
PPTX
Identity, authentication and authorization
PPTX
Help! I Have An Identity Crisis: A look at various mechanisms of Single Sign On
PDF
JavaOne 2014 - Securing RESTful Resources with OAuth2
PDF
Full stack security
PDF
Cloud Native Identity with SPIFFE
PPTX
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
PDF
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...
PPTX
API Security : Patterns and Practices
PDF
How we implemented SSO into a zero knowledge cloud encryption solution
PDF
Json web token api authorization
PDF
OAuth 2.0 – A standard is coming of age by Uwe Friedrichsen
PDF
Let's get evil - threat modeling at scale
PDF
OAuth 2.0
PDF
2016 pycontw web api authentication
PDF
Authentication: Cookies vs JWTs and why you’re doing it wrong
PPTX
Draft: building secure applications with keycloak (oidc/jwt)
PPTX
REST Service Authetication with TLS & JWTs
FIDO2 Specifications Overview
DEF CON 27 - ALVARO MUNOZ / OLEKSANDR MIROSH - sso wars the token menace
Internet banking safeguards vulnerabilities - OWASP AppSec EU 2016
Identity, authentication and authorization
Help! I Have An Identity Crisis: A look at various mechanisms of Single Sign On
JavaOne 2014 - Securing RESTful Resources with OAuth2
Full stack security
Cloud Native Identity with SPIFFE
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...
API Security : Patterns and Practices
How we implemented SSO into a zero knowledge cloud encryption solution
Json web token api authorization
OAuth 2.0 – A standard is coming of age by Uwe Friedrichsen
Let's get evil - threat modeling at scale
OAuth 2.0
2016 pycontw web api authentication
Authentication: Cookies vs JWTs and why you’re doing it wrong
Draft: building secure applications with keycloak (oidc/jwt)
REST Service Authetication with TLS & JWTs
Ad

Viewers also liked (10)

ODP
E learning-for-all-devices
PPTX
Odata batch processing
PPTX
Open office doc inside windows metro app
PPTX
Mobile engagement platform
PPT
Android overview
PPTX
Lync integration with metro app
PPTX
Side loading
PPTX
Gcm and share point integration
PPTX
Agile QA process
ODP
Android crash debugging
E learning-for-all-devices
Odata batch processing
Open office doc inside windows metro app
Mobile engagement platform
Android overview
Lync integration with metro app
Side loading
Gcm and share point integration
Agile QA process
Android crash debugging
Ad

Similar to Client certificate validation in windows 8 (20)

PDF
Denis Zhuchinski Ways of enhancing application security
PDF
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"
PDF
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
PPTX
Create Your Own Serverless PKI with .NET & Azure Key Vault
PDF
Certificate Pinning in Mobile Applications
PDF
Microsoft Bluehat 2017: Mobile SSL Interception
DOCX
How to validate server certificate
PPTX
Let's encrypt
PDF
Steam Learn: HTTPS and certificates explained
PDF
You wanna crypto in AEM
PPTX
Cqcon2015
PPT
certificates.ppt
PPTX
Secure socket layer
 
PDF
Android P Security Updates: What You Need to Know
PPTX
Cryptography by Afroz haider mir
PDF
Windows Certification Full
PDF
June OpenNTF Webinar - Domino V12 Certification Manager
PDF
Wildcard and SAN - Understanding Multi Domain SSL Certificate
PPTX
Spsbe15 high-trust apps for on-premises development
PPTX
SPS Belgium 2015 - High-trust Apps for On-Premises Development
Denis Zhuchinski Ways of enhancing application security
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"
.NET Fest 2019. Eran Stiller. Create Your Own Serverless PKI with .NET & Azur...
Create Your Own Serverless PKI with .NET & Azure Key Vault
Certificate Pinning in Mobile Applications
Microsoft Bluehat 2017: Mobile SSL Interception
How to validate server certificate
Let's encrypt
Steam Learn: HTTPS and certificates explained
You wanna crypto in AEM
Cqcon2015
certificates.ppt
Secure socket layer
 
Android P Security Updates: What You Need to Know
Cryptography by Afroz haider mir
Windows Certification Full
June OpenNTF Webinar - Domino V12 Certification Manager
Wildcard and SAN - Understanding Multi Domain SSL Certificate
Spsbe15 high-trust apps for on-premises development
SPS Belgium 2015 - High-trust Apps for On-Premises Development

Recently uploaded (20)

PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
web development for engineering and engineering
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
CH1 Production IntroductoryConcepts.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
OOP with Java - Java Introduction (Basics)
Model Code of Practice - Construction Work - 21102022 .pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
web development for engineering and engineering
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
bas. eng. economics group 4 presentation 1.pptx
Lecture Notes Electrical Wiring System Components
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx

Client certificate validation in windows 8

  • 1. Client Certificate validation in Windows 8/8.1 winRT app -Ashish Agrawal
  • 2. Problem Statement • How to do certificate validation in windows RT metro app.
  • 3. Binary Security Based token authentication • <wsse:BinarySecurityToken Id="Compact0">ABCD</wsse:BinarySecurityToken> • In non encrypted token response, we directly get the binary Security token from where we can get the RTFA and FEDAuth cookies and communicate with the server. • https://login.partner.microsoftonline.cn should be hit to get the encrypted token
  • 4. Encrypted token • <wst:RequestedSecurityToken> • <EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Id="Assertion0" Type="http://www.w3.org/2001/04/xmlenc#Element"> • <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"></EncryptionMethod> • <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> • <EncryptedKey> • <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"></EncryptionMethod> • <ds:KeyInfo> • <ds:X509Data> • <ds:X509SKI>ac4GbK23Iw/V29Ef4tJAaZwrR6I=</ds:X509SKI> • </ds:X509Data> • <ds:KeyName>sharepoint.cn</ds:KeyName> • </ds:KeyInfo> • <CipherData> • <CipherValue>ABCD</CipherValue> • </CipherData> • </EncryptedKey> • </ds:KeyInfo> •
  • 5. • <CipherData> • <CipherValue>XXX/CipherData> • </EncryptedData> • </wst:RequestedSecurityToken> • <wst:RequestedAttachedReference> • <wsse:SecurityTokenReference> • <wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID">uuid- e36c6939-c283-4c68-ad2e-8e5720b9c51a</wsse:KeyIdentifier> • </wsse:SecurityTokenReference> • </wst:RequestedAttachedReference> • <wst:RequestedUnattachedReference> • <wsse:SecurityTokenReference> • <wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID">uuid- e36c6939-c283-4c68-ad2e-8e5720b9c51a</wsse:KeyIdentifier> • </wsse:SecurityTokenReference> • </wst:RequestedUnattachedReference> • <wst:RequestedProofToken> • <wst:BinarySecret>8TM1ybkRA1Y4QURgKaIlzu7gywlQscqI</wst:BinarySecret> • </wst:RequestedProofToken> • </wst:RequestSecurityTokenResponse> Encrypted token cont..
  • 6. The data encryption process can be understood from below link: • http://msdn.microsoft.com/en- us/library/vstudio/aa967562(v=vs.90).aspx
  • 7. How to get locally installed certificate in WinRTapp • In-order to access locally installed X509 certificated, the below capability need to be enabled in app manifest • <Capabilities> • <Capability Name="internetClient" /> • <Capability Name="sharedUserCertificates" /> • </Capabilities>
  • 8. Code to access local certificate • use Windows.Security (System.Security namespace is unavailable in winRT apps) • Windows.Security.Cryptography.Certificates.CertificateQuery cq = new Windows.Security.Cryptography.Certificates.CertificateQuery(); cq.Thumbprint = data; (Create certificate query using the thumbprint received from encrypted token xml. ds:X509SKI) • IEnumerable<Certificate> certificates = await CertificateStores.FindAllAsync(cq); (Using the certificate query we can access all the local certificates)
  • 9. How to get Rtfa and FedAuth cookie • Once we get the desired certificate based on the certificate query, we should get its private key and use it to decrypt the cipher data: • <CipherData> • <CipherValue>ABCD</CipherValue> • </CipherData> • This decrypted key should be used to further decrypt the RequestedSecurityToken and get the actual cookie (rtfa and fedauth)
  • 10. Incase required certificate is not present locally. Certificate enrollment • Security server specially bank servers provide certificate enrollment API which provide certificate to be used to validation. • http://msdn.microsoft.com/en-US/library/windows/apps/hh464943
  • 11. Create Certificate Request • Create certificate request properties with the required parameters: • CertificateRequestProperties reqProperties = new CertificateRequestProperties(); • reqProperties.KeyUsages = EnrollKeyUsages.Signing; • reqProperties.FriendlyName = "Ashish"; • Make a request using the certificate properties • String cert = await CertificateEnrollmentManager.CreateRequestAsync(reqProperties);
  • 12. Get certificate from server for decryption • string postJsonData = "{"Username":"zhao@saifdemo.partner.onmschina.cn","&Password":"password01!"}"; • var clientHandler = new HttpClientHandler(); • byte[] responsecert = await SpCommon.SendHttpRequest( new Uri(“SERVERURL"), HttpMethod.Post, new MemoryStream(Encoding.UTF8.GetBytes(postJsonData)), "application/x-www-form-urlencoded", clientHandler); • if (responsecert != null) • { • // parse the required x509 certificate response • }
  • 13. Thanks. • For any queries Contact me : meetashish@gmail.com