SlideShare una empresa de Scribd logo
1 de 21
Elektroniskā paraksta integrācija informācijas sistēmāsPubliskie servisi izstrādātājiem
Saturs Sertifikāta uzticamības pārbaude Sertifikāta statusa publicēšana ,[object Object]
OCSPLaika zīmogu serviss LDAP direktorijs
Kopskats (parakstīšana, autentificēšana) eDokumenta nosūtīšana Parakstītājs Pārbaudītājs OCSP  (over HTTP) TSP  (over HTTPS) HTTP LDAP v3 LDAP v3 LDAP v3 HTTP Laika zīmogu serviss On-line statusa serviss CRL novietne AIA novietne Sertifikātu direktorijs LVRTC e-me
Kopskats (šifrēšana) Šifrētās informācijas  nosūtīšana Šifrētājs Saņēmējs OCSP  (over HTTP) TSP  (over HTTPS) HTTP LDAP v3 LDAP v3 LDAP v3 HTTP Laika zīmogu serviss On-line statusa serviss CRL novietne AIA novietne Sertifikātu direktorijs LVRTC e-me
Sertifikāta uzticamības pārbaude Saknes sertifikātam jābūt uzticamam Pārbauda visu sertifikātu parakstus Izmanto info sertifikātā OCSP  (over HTTP) TSP  (over HTTPS) HTTP LDAP v3 LDAP v3 LDAP v3 HTTP Laika zīmogu serviss On-line statusa serviss CRL novietne AIA novietne Sertifikātu direktorijs LVRTC e-me
Demo Sertifikāta ķēdes un derīguma termiņa pārbaude
Sertifikāta ķēdes un aktivitātes pārbaude Statuss CRL sarakstos netiks pārbaudīts – tiks veidota tikai sertifikātu ķēde     private bool IsTrustedAndActive(X509Certificate2 subjectCertificate)        {            // build chain to validate all signatures in it            // (do not check statuses in this step)            X509Chain chain = new X509Chain();            chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;            bool chainBuilt = chain.Build(subjectCertificate);            if (chainBuilt)            {                // check if at the moment certificate is active (i.e., not                // before its actication date and not after its expiry date)                DateTime validationDateAndTime = DateTime.Now;                if (subjectCertificate.NotBefore <= validationDateAndTime &&                    subjectCertificate.NotAfter >= validationDateAndTime)                {                    return true;                }            }            return false;        } Pārbaudi veicam pēc pašreizējā datuma.  Dokumentu pārbaudē, iespējams, jāveic pēc dokumenta parakstīšanas datuma
Sertifikāta statusa publicēšana OCSP  (over HTTP) TSP  (over HTTPS) HTTP LDAP v3 LDAP v3 LDAP v3 HTTP Laika zīmogu serviss On-line statusa serviss CRL novietne AIA novietne Sertifikātu direktorijs  LVRTC e-me
OCSP  3. Pārbauda OCSP atbildes parakstu un OCSP sertifikāta derīgumu (AIA, CRL, paraksta pārbaude) 2. Saņem OCSP atbildi 1. Pieprasa 1 – N sertifikātu statusa informāciju Pārbaudītājs Atbildes statuss Masīvs no: OCSP paraksts Masīvs no: Statuss Izdevēja ID Detaļas Sertifikāta ID Sertifikāta ID OCSP  (over HTTP) On-line statusa serviss
Demo Sertifikāta statusa pārbaude (CRL, OCSP)
Sertifikāta statusa pārbaude CRL Statuss CRL sarakstos tiek pārbaudīts, izmantojot kešotos CRL sarakstus klienta datorā (ja tādi ir)             X509Chain chain = new X509Chain();            chain.ChainPolicy.RevocationMode = X509RevocationMode.Offline;            bool chainBuiltAndStatusesOK = chain.Build(subjectCertificate); Ja mainīgā vērtība True, tad pārbaude veiksmīga un statusi visas ķēdes sertifikātiem ir OK
Sertifikāta statusa pārbaude OCSP Cert ir X509Certificate2 klases instance, kas satur pārbaudāmo sertifikātu                     // validate certificate using OCSP                OcspClient ocspClient = new OcspClient(new Uri("https://ocsp.eme.lv/responder.eme"));                ocspClient.Verify = true;                OcspRequest ocspRequest = new OcspRequest();                ocspRequest.Certs.Add(                    MakeCertID(cert)                    );                OcspResponse ocspResponse = ocspClient.QueryOcspServer(ocspRequest);                if (ocspResponse.Status == OcspResponseType.Good &&                     ocspResponse.Certs[0].RevocationStatus.Status == CertificateStatusType.Good)                {                    certificateOk = true;                }                else                {                    certificateOk = false;                } Prasījām statusu tikai par vienu sertifikātu – tāpēc varam pārbaudīt tikai pirmo atbildi         private CertID MakeCertID(X509Certificate2 subjectCertificate) // helpsbuildcertidneededbyfindingissuer        {            X509Chain chain = new X509Chain();            chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;            bool chainBuilt = chain.Build(subjectCertificate);            X509Certificate2 issuerCertificate = null;            foreach (var chainElement in chain.ChainElements)            {                if (chainElement.Certificate.Subject == subjectCertificate.Issuer)                    issuerCertificate = chainElement.Certificate;            }            return new CertID(issuerCertificate, new CertificateSerialNumber(subjectCertificate.SerialNumber.Replace("-", "")),  ObjectId.Sha1);        }
Laika zīmogu serviss 3. Pārbauda TSA atbildes parakstu un TSA sertifikāta derīgumu (AIA, CRL/OCSP,  paraksta pārbaude) 2. Saņem TSA atbildi 1. Autentificējas,  pieprasa laika zīmogu Parakstītājs Atbildes statuss TSA paraksts {TSA sertifikāts} Dokumenta hash Dokumenta hash Datums un laiks TSP  (over HTTPS) Laika zīmogu serviss
Demo Laika zīmoga pieprasīšana
Laika zīmoga pieprasīšana Palīgmetode lūdz lietotājam izvēlēties klienta autentifikācijas sertifikātu                 TsaClient client = new TsaClient(new Uri("https://tsa.eme.lv/responder.eme"));                X509Certificate2 authCertificate = GetCertificate();                if (authCertificate != null)                {                    client.ClientCert = authCertificate;                    TsaRequest request = new TsaRequest();                    request.CertificateRequired = true;                    request.Imprint = new TsaMessageImprint(new SHA1Managed().ComputeHash(signature));                    TsaResponse response = client.QueryTsaServer(request);                    if ((response.ResponseType == TsaResponseType.Granted || response.ResponseType == TsaResponseType.GrantedWithMods))                    {                        timestampTextBox.Text = string.Format("Timestamp issued. Time = {0}", response.SignedData.Time.ToString());                    }                    else                    {                        timestampTextBox.Text = string.Format("TsaResponseType = {0}, TsaFailureType = {1}",  response.ResponseType.ToString(), response.FailureType.ToString());                    }                } Atbildē pieprasām iekļaut TSA sertifikātu     Paraksts, kuru zīmogosim (baitu masīvs, kas izveidots, parakstot)
Sertifikātu meklēšana direktorijā 3. Nolasa nepieciešamos  atribūtus (sertifikātu) un šifrē nosūtāmo ziņojumu 2. Saņem LDAP atbildi 1. Nosūta meklēšanas pieprasījumu Šifrētājs Saraksts ar atrastajiem elementiem Base: c=lv Query: (&(givenName=Aldis) (sn=Viļums)) Attributes: Nolasāmo atribūtu saraksts LDAP v3 Sertifikātu direktorijs
Sertifikātu direktorija struktūra C = LV  O = E-ME OU = Sertifikācijas pakalpojumu daļa CN = E-ME PSI (PCA) LDAP objektu klase inetOrgPerson CN = E-ME SI (CA1) UID=<sertifkāta seriālais #> UID=<sertifkāta seriālais #> CN = E-ME SSI (RCA)
Personas sertifikāta ieraksta informācija
Demo Informācijas meklēšana LDAP
Informācijas meklēšana LDAP                     LdapDirectoryIdentifier ldapId = new LdapDirectoryIdentifier("eme.lv", false, false);                SearchRequest searchRequest = new SearchRequest(                    "c=lv", // base path to search from                     "(&(givenName=Janis)(sn=Berzins))", // filter string to search for entries having name Janis and surname Berzins                    System.DirectoryServices.Protocols.SearchScope.Subtree, // search in the whole subtree under c=lv                    "cn", "givenName", "sn", "serialNumber", "uid", "mail", "o", "ou", "userCertificate" // get these attributes                    );                                LdapConnection ldapConn = new LdapConnection(ldapId, null, AuthType.Anonymous); // use anonymous connection                ldapConn.SessionOptions.ProtocolVersion = 3;                                SearchResponse response = (SearchResponse)ldapConn.SendRequest(searchRequest);                foreach (SearchResultEntry resultEntry in response.Entries)                {                    Console.WriteLine("  {0}", resultEntry.DistinguishedName);                    // print out basic information                    foreach (string attributeName in resultEntry.Attributes.AttributeNames)                    {                        if (resultEntry.Attributes[attributeName].Count > 0)                        {                            string attributeValue = (string)(resultEntry.Attributes[attributeName].GetValues(typeof(string))[0]);                            if (attributeName.ToLowerInvariant() != "usercertificate")                                Console.WriteLine("    {0}: {1}", attributeName, attributeValue);                        }                    }                    // code below shows how to get a certificate                    byte[] fileContents = (byte[])(resultEntry.Attributes["userCertificate"].GetValues(typeof(byte[]))[0]);                    Console.WriteLine(Convert.ToBase64String(fileContents));                }

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

LVRTC publiskie servisi: CRL un OCSP, laika zīmogi, LDAP

  • 1. Elektroniskā paraksta integrācija informācijas sistēmāsPubliskie servisi izstrādātājiem
  • 2.
  • 3. OCSPLaika zīmogu serviss LDAP direktorijs
  • 4. Kopskats (parakstīšana, autentificēšana) eDokumenta nosūtīšana Parakstītājs Pārbaudītājs OCSP (over HTTP) TSP (over HTTPS) HTTP LDAP v3 LDAP v3 LDAP v3 HTTP Laika zīmogu serviss On-line statusa serviss CRL novietne AIA novietne Sertifikātu direktorijs LVRTC e-me
  • 5. Kopskats (šifrēšana) Šifrētās informācijas nosūtīšana Šifrētājs Saņēmējs OCSP (over HTTP) TSP (over HTTPS) HTTP LDAP v3 LDAP v3 LDAP v3 HTTP Laika zīmogu serviss On-line statusa serviss CRL novietne AIA novietne Sertifikātu direktorijs LVRTC e-me
  • 6. Sertifikāta uzticamības pārbaude Saknes sertifikātam jābūt uzticamam Pārbauda visu sertifikātu parakstus Izmanto info sertifikātā OCSP (over HTTP) TSP (over HTTPS) HTTP LDAP v3 LDAP v3 LDAP v3 HTTP Laika zīmogu serviss On-line statusa serviss CRL novietne AIA novietne Sertifikātu direktorijs LVRTC e-me
  • 7. Demo Sertifikāta ķēdes un derīguma termiņa pārbaude
  • 8. Sertifikāta ķēdes un aktivitātes pārbaude Statuss CRL sarakstos netiks pārbaudīts – tiks veidota tikai sertifikātu ķēde     private bool IsTrustedAndActive(X509Certificate2 subjectCertificate)        {            // build chain to validate all signatures in it            // (do not check statuses in this step)            X509Chain chain = new X509Chain();            chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;            bool chainBuilt = chain.Build(subjectCertificate);            if (chainBuilt)            {                // check if at the moment certificate is active (i.e., not                // before its actication date and not after its expiry date)                DateTime validationDateAndTime = DateTime.Now;                if (subjectCertificate.NotBefore <= validationDateAndTime &&                    subjectCertificate.NotAfter >= validationDateAndTime)                {                    return true;                }            }            return false;        } Pārbaudi veicam pēc pašreizējā datuma. Dokumentu pārbaudē, iespējams, jāveic pēc dokumenta parakstīšanas datuma
  • 9. Sertifikāta statusa publicēšana OCSP (over HTTP) TSP (over HTTPS) HTTP LDAP v3 LDAP v3 LDAP v3 HTTP Laika zīmogu serviss On-line statusa serviss CRL novietne AIA novietne Sertifikātu direktorijs LVRTC e-me
  • 10. OCSP 3. Pārbauda OCSP atbildes parakstu un OCSP sertifikāta derīgumu (AIA, CRL, paraksta pārbaude) 2. Saņem OCSP atbildi 1. Pieprasa 1 – N sertifikātu statusa informāciju Pārbaudītājs Atbildes statuss Masīvs no: OCSP paraksts Masīvs no: Statuss Izdevēja ID Detaļas Sertifikāta ID Sertifikāta ID OCSP (over HTTP) On-line statusa serviss
  • 11. Demo Sertifikāta statusa pārbaude (CRL, OCSP)
  • 12. Sertifikāta statusa pārbaude CRL Statuss CRL sarakstos tiek pārbaudīts, izmantojot kešotos CRL sarakstus klienta datorā (ja tādi ir)             X509Chain chain = new X509Chain();            chain.ChainPolicy.RevocationMode = X509RevocationMode.Offline;            bool chainBuiltAndStatusesOK = chain.Build(subjectCertificate); Ja mainīgā vērtība True, tad pārbaude veiksmīga un statusi visas ķēdes sertifikātiem ir OK
  • 13. Sertifikāta statusa pārbaude OCSP Cert ir X509Certificate2 klases instance, kas satur pārbaudāmo sertifikātu                     // validate certificate using OCSP                OcspClient ocspClient = new OcspClient(new Uri("https://ocsp.eme.lv/responder.eme"));                ocspClient.Verify = true;                OcspRequest ocspRequest = new OcspRequest();                ocspRequest.Certs.Add(                    MakeCertID(cert)                    );                OcspResponse ocspResponse = ocspClient.QueryOcspServer(ocspRequest);                if (ocspResponse.Status == OcspResponseType.Good &&                     ocspResponse.Certs[0].RevocationStatus.Status == CertificateStatusType.Good)                {                    certificateOk = true;                }                else                {                    certificateOk = false;                } Prasījām statusu tikai par vienu sertifikātu – tāpēc varam pārbaudīt tikai pirmo atbildi         private CertID MakeCertID(X509Certificate2 subjectCertificate) // helpsbuildcertidneededbyfindingissuer        {            X509Chain chain = new X509Chain();            chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;            bool chainBuilt = chain.Build(subjectCertificate);            X509Certificate2 issuerCertificate = null;            foreach (var chainElement in chain.ChainElements)            {                if (chainElement.Certificate.Subject == subjectCertificate.Issuer)                    issuerCertificate = chainElement.Certificate;            }            return new CertID(issuerCertificate, new CertificateSerialNumber(subjectCertificate.SerialNumber.Replace("-", "")),  ObjectId.Sha1);        }
  • 14. Laika zīmogu serviss 3. Pārbauda TSA atbildes parakstu un TSA sertifikāta derīgumu (AIA, CRL/OCSP, paraksta pārbaude) 2. Saņem TSA atbildi 1. Autentificējas, pieprasa laika zīmogu Parakstītājs Atbildes statuss TSA paraksts {TSA sertifikāts} Dokumenta hash Dokumenta hash Datums un laiks TSP (over HTTPS) Laika zīmogu serviss
  • 15. Demo Laika zīmoga pieprasīšana
  • 16. Laika zīmoga pieprasīšana Palīgmetode lūdz lietotājam izvēlēties klienta autentifikācijas sertifikātu                 TsaClient client = new TsaClient(new Uri("https://tsa.eme.lv/responder.eme"));                X509Certificate2 authCertificate = GetCertificate();                if (authCertificate != null)                {                    client.ClientCert = authCertificate;                    TsaRequest request = new TsaRequest();                    request.CertificateRequired = true;                    request.Imprint = new TsaMessageImprint(new SHA1Managed().ComputeHash(signature));                    TsaResponse response = client.QueryTsaServer(request);                    if ((response.ResponseType == TsaResponseType.Granted || response.ResponseType == TsaResponseType.GrantedWithMods))                    {                        timestampTextBox.Text = string.Format("Timestamp issued. Time = {0}", response.SignedData.Time.ToString());                    }                    else                    {                        timestampTextBox.Text = string.Format("TsaResponseType = {0}, TsaFailureType = {1}",  response.ResponseType.ToString(), response.FailureType.ToString());                    }                } Atbildē pieprasām iekļaut TSA sertifikātu     Paraksts, kuru zīmogosim (baitu masīvs, kas izveidots, parakstot)
  • 17. Sertifikātu meklēšana direktorijā 3. Nolasa nepieciešamos atribūtus (sertifikātu) un šifrē nosūtāmo ziņojumu 2. Saņem LDAP atbildi 1. Nosūta meklēšanas pieprasījumu Šifrētājs Saraksts ar atrastajiem elementiem Base: c=lv Query: (&(givenName=Aldis) (sn=Viļums)) Attributes: Nolasāmo atribūtu saraksts LDAP v3 Sertifikātu direktorijs
  • 18. Sertifikātu direktorija struktūra C = LV O = E-ME OU = Sertifikācijas pakalpojumu daļa CN = E-ME PSI (PCA) LDAP objektu klase inetOrgPerson CN = E-ME SI (CA1) UID=<sertifkāta seriālais #> UID=<sertifkāta seriālais #> CN = E-ME SSI (RCA)
  • 21. Informācijas meklēšana LDAP                     LdapDirectoryIdentifier ldapId = new LdapDirectoryIdentifier("eme.lv", false, false);                SearchRequest searchRequest = new SearchRequest(                    "c=lv", // base path to search from                     "(&(givenName=Janis)(sn=Berzins))", // filter string to search for entries having name Janis and surname Berzins                    System.DirectoryServices.Protocols.SearchScope.Subtree, // search in the whole subtree under c=lv                    "cn", "givenName", "sn", "serialNumber", "uid", "mail", "o", "ou", "userCertificate" // get these attributes                    );                                LdapConnection ldapConn = new LdapConnection(ldapId, null, AuthType.Anonymous); // use anonymous connection                ldapConn.SessionOptions.ProtocolVersion = 3;                                SearchResponse response = (SearchResponse)ldapConn.SendRequest(searchRequest);                foreach (SearchResultEntry resultEntry in response.Entries)                {                    Console.WriteLine("  {0}", resultEntry.DistinguishedName);                    // print out basic information                    foreach (string attributeName in resultEntry.Attributes.AttributeNames)                    {                        if (resultEntry.Attributes[attributeName].Count > 0)                        {                            string attributeValue = (string)(resultEntry.Attributes[attributeName].GetValues(typeof(string))[0]);                            if (attributeName.ToLowerInvariant() != "usercertificate")                                Console.WriteLine("    {0}: {1}", attributeName, attributeValue);                        }                    }                    // code below shows how to get a certificate                    byte[] fileContents = (byte[])(resultEntry.Attributes["userCertificate"].GetValues(typeof(byte[]))[0]);                    Console.WriteLine(Convert.ToBase64String(fileContents));                }