Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3 . 6 Task 6 : Manually Verifying an X . 5 0 9 Certificate In this task, we will manually verify an X .
Task : Manually Verifying an X Certificate
In this task, we will manually verify an X certificate using our program. An X contains data about
a public key and an issuers signature on the data. We will download a real X certific
ate from a web
server, get its issuers public key, and then use this public key to verify the signature on the certificate.
Step : Download a certificate from a real web server. We use the wwwexample.org server in
this document. Students should choose a different web server that has a different certificate than the
one used in this document it should be noted that wwwexample.com share the same certificate with
wwwexample.org We can download certificates using browsers or use the following command:
$ openssl sclientconnect wwwexample.org:showcerts
Certificate chain
s:CUSSTCaliforniaLLos AngelesOInternet Corporation for Assigned
Names and NumbersOUTechnologyCNwwwexample.org
i:CUSODigiCert IncOUwwwdigicert.comCNDigiCert SHA High Assurance
Server CABEGIN CERTIFICATE
MIIFjCCBNqgAwIBAgIQDmTFIreFLFyrrQceMsDANBgkqhkiGwBAQsFADBw
MQswCQYDVQQGEwJVUzEVMBMGAUEChMMRGlnaUNlcnQgSWjMRkwFwYDVQQLExB
wDSiIIWIWJiJGbEeIOTIFwEVWTOnbNlfaPXpkIRXicapqiIIEND CERTIFICATE
s:CUSODigiCert IncOUwwwdigicert.comCNDigiCert SHA High
Assurance Server CA
i:CUSODigiCert IncOUwwwdigicert.comCNDigiCert High Assurance
EV Root CABEGIN CERTIFICATE
MIIEsTCCAmgAwIBAgIQBOHnpNxcvNtwCtCuFVnzANBgkqhkiGwBAQsFADBs
MQswCQYDVQQGEwJVUzEVMBMGAUEChMMRGlnaUNlcnQgSWjMRkwFwYDVQQLExB
cPUeybQEND CERTIFICATE
The result of the command contains two certificates. The subject field the entry starting with s: of
the certificate is wwwexample.org, ie this is wwwexample.orgs certificate. The issuer field the
entry starting with i: provides the issuers information. The subject field of the second certificate is the
same as the issuer field of the first certificate. Basically, the second certificate belongs to an intermediate
CA In this task, we will use CAs certificate to verify a server certificate.
If you only get one certificate back using the above command, that means the certificate you get is signed
by aroot CA Root CAs certificates can be obtained from the Firefox browser installed in our prebuilt VM
Gotothe Edit Preferences PrivacyandthenSecurity View Certificates. Search
for the name of the issuer and download its certificate.
Copy and paste each of the certificate the text between the line containing "Begin CERTIFICATE"
and the line containing "END CERTIFICATE", including these two lines to a file. Let us call the first one
cpem and the second one cpem.
Step : Extract the public key e n from the issuers certificate. Openssl provides commands to
extract certain attributes from the x certificates. We can extract the value of n usingmodulus. There
is no specific command to extract e but we can print out all the fields and can easily find the value of e
SEEDLabsRSAPublicKeyEncryptionandSignatureLab
Formodulusn:
$opensslxincpemnooutmodulus
Printoutallthefields,find theexponente:
$opensslxincpemtextnoout
Step:Extractthesignaturefromtheserverscertificate Thereisnospecificopensslcommandto
extract thesignaturefield. However,wecanprintoutall thefieldsandthencopyandpastethesignature
blockintoafilenote: ifthesignaturealgorithmusedinthecertificateisnotbasedonRSA,youcanfind
anothercertificate
$opensslxincpemtextnoout
SignatureAlgorithm:shaWithRSAEncryption
:a:a::a:d:bd:b::e:::b:b::d:ea::
::::f:a:ed::ea:b:e:b:c:d:::e:dd:
c::::ce:d:b::fd:f:f:e:::::e::
aa:a::
Weneedtoremovethespacesandcolonsfromthedata,sowecangetahexstringthatwecanfeedinto
ourprogram.Thefollowingcommandcommandscanachievethisgoal.ThetrcommandisaLinuxutility
toolforstringoperations. Inthiscase,thedoptionisusedtodelete":"and"space"fromthedata.
$catsignaturetrd:space::
aaadbdbebbdeafaedeabebc
ccedbfdffeeaaa
Step:Extractthebodyoftheserverscertificate ACertificateAuthorityCAgeneratesthesignature
foraservercertificatebyfirstcomputingthehashof thecertificate,andthensignthehash. Toverifythe
signature,wealsoneedtogenerate thehashfromacertificate. Since thehashisgeneratedbefore the
signatureiscomputed,weneedtoexcludethesignatureblockofacertificatewhencomputingthehash.
Findingoutwhatpartof thecertificateisusedtogeneratethehashisquitechallengingwithoutagood
understandingoftheformatofthecertificate.
XcertificatesareencodedusingtheASNAbstractSyntaxNotationOnestandardsoifwecan
parsetheASNstructure,wecaneasilyextractanyfieldfromacertificate.Opensslhasacommandcalled
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started