ocsp

Microsoft OCSP LogSource

Written by  on August 30, 2016

Sowohl in Windows 2008R2 wie auch in Windows 2012R2 schreibt der Microsoft OCSP Responder seine Logs mit der Source „OnlineResponder“ in den Eventviewer. Was passiert aber, wenn man testweise Einträge erzeugen möchte, etwa um ein Script zu triggern, dass auf bestimmte Logeinträge reagieren soll?
Für Windows 2008R2 heißt die Source plötzlich OCSPSvc:

$EvtSource="OCSPSvc"
Write-Eventlog Application -Source $EvtSource -EventID 36 -EntryType Info -Message "Test"

Unter Windows 2012R2 klappt es aber wieder nicht, hier heißt die Source wieder anders: Microsoft-Windows-OnlineResponder

$EvtSource="Microsoft-Windows-OnlineResponder"
Write-Eventlog Application -Source $EvtSource -EventID 36 -EntryType Info -Message "Test"

OCSP Responder Monitoring und die Nonce

Written by  on Februar 18, 2016

Eine Nonce, aus dem Englichen für „Number ONCE“, ist eine Nummer die nur ein Mal verwendet werden soll. Diese Nummer wird vom OCSP Client generiert, mit der Anfrage mitgeschickt. Der OCSP Responder muss den Wert in der signierten Antwort mitschicken, zur Bestätigung dass es sich tatsächlich um die entsprechende Antwort auf die Anfrage handelt. Das dient einerseits als Schutz vor einer Replay Attacke, hat aber auch den „Nachteil“ dass die Antwort nicht gecached werden kann. Und genau das ist für ein Monitoring von Vorteil, weil damit erkannt werden kann, ob tatsächlich neue OCSP Responses erzeugt werden, und nicht nur irgendwelche Antworten aus einem Cache fallen.
In RFC5019 heißt es zur Nonce beim OCSP Responder, dass sich der Client nicht alleine auf den Nonce verlassen darf, sondern im Zweifelsfall auch noch den Timestamp prüfen muss.

Clients that opt to include a nonce in the request SHOULD NOT reject a corresponding OCSPResponse solely on the basis of the nonexistent expected nonce, but MUST fall back to validating the OCSPResponse based on time. Clients that do not include a nonce in the request MUST ignore any nonce that may be present in the response.

Microsoft zu OCSP, Nonce und Cache

Allow Nonce requests. This option instructs the Online Responder to inspect and process an OCSP request nonce extension. If a nonce extension is included in the OCSP request and this option is selected, the Online Responder will ignore any cached OCSP response and will create a new response that includes the nonce provided in the request. If this option is disabled and a request that includes a nonce extension is received, the Online Responder will reject the request with an „unauthorized“ error.

Microsoft sagt in der gleichen Quelle übrigens, dass Microsoft Clients mit aktuellem Stand keine Nonce unterstützen

The Microsoft OCSP client does not support the nonce extension.

Ocsp Responder Caching

Written by  on Februar 5, 2016

Dreht man einen Microsoft OCSP Responder ab, schlägt das Monitoring darauf nicht an. Warum?

Weil die OCSP Responses vom IIS gecached werden und zwar für so lange wie auch die CRL noch gültig wäre!

Response caching. After a request is received and a certificate serial number is extracted, the Online Responder Web proxy will check the local cache for a valid response. The cache is implemented as part of the ISAPI extension and is an in-memory cache. If a client request generates a cache fault, the Online Responder Web proxy will make a request to the Online Responder service for a response. The cache item validity period is set to the CRL validity period from which the response was generated or to the signing key validity, whichever is shorter.

Zusätzlich wird noch für 120 Sekunden gecached.

In addition to the OCSP ISAPI extension caching, the IIS HTTP.SYS library performs caching for 120 seconds. Multiple requests to the Online Responder in that time period will be served with the HTTP.SYS-cached response.

Online Responder Installation, Configuration, and Troubleshooting Guide

Testing OCSP

Written by  on Dezember 23, 2015

To test OCSP you need three things: The issuer certificate, the certificate you’d like to check and the path to the OCSP. All this information seems to be slightly redundant, as the certificate itself already contains the information about the OCSP URL and most of the time also the path to the issuer certificate. It would be very nice if openssl would read all this information from the certificate itself, nevertheless you need this three things to do some basic checks.
Get the required information from the AIA and download the issuer certificate:

[1]Authority Info Access
     Access Method=On-line Certificate Status Protocol (1.3.6.1.5.5.7.48.1)
     Alternative Name:
          URL=http://ocsp.startssl.com/sub/class1/server/ca
[2]Authority Info Access
     Access Method=Certification Authority Issuer (1.3.6.1.5.5.7.48.2)
     Alternative Name:
          URL=http://aia.startssl.com/certs/sub.class1.server.ca.crt

Write the request into a file

openssl ocsp -issuer startssl.cer -cert www.höllrigl.at.cer -no_nonce -url http://ocsp.startssl.com/sub/class1/server/ca -reqout ocsp.req

Convert the request to base64

openssl enc -in ocsp.req -out ocsp.req.b64 -a

The file should look something like this

MEswSTBHMEUwQzAJBgUrDgMCGgUABAR571c85Prvkggz7EWCVSbdzaAjFQQUFbqc
WolwWaxKVTlvLQA1YeCBz7MCChnePRMAAAAArhA=

Then you URL encode that file – you might use some free online decoder like http://meyerweb.com/eric/tools/dencoder/ – but here you have to remove the line breaks in advance. Or you do it directly at the shell

tr -d '\n' < ocsp.req.b64 | php -R 'echo urlencode($argn);'

Your output should look something like

MEswSTBHMEUwQzAJBgUrDgMCGgUABAR571c85Prvkggz7EWCVSbdzaAjFQQUFbqcWolwWaxKVTlvLQA1YeCBz7MCChnePRMAAAAArhA%3D

Now you can build your request to submit in a webbrowser or using curl at the shell.

curl http://ocsp.startssl.com/sub/class1/server/ca/MEswSTBHMEUwQzAJBgUrDgMCGgUABAR571c85Prvkggz7EWCVSbdzaAjFQQUFbqcWolwWaxKVTlvLQA1YeCBz7MCChnePRMAAAAArhA%3D --proxy http://path.to.proxy:8080 > ocsp.resp

With the output file you are able to verify the output with something like

openssl ocsp -respin ocsp.resp -text
OCSP Response Data:
    OCSP Response Status: successful (0x0)
...

Why all this effort, when openssl might do this on it’s own?
Just because openssl won’t work too well in an envrionment where a proxy is required.
The –proxy option seems only to work starting with version openssl 1.1

Alternatively you could also try telnet to connect via a proxy

telnet path.to.proxy 8080
CONNECT ocsp.startssl.com:80 HTTP/1.0
GET /sub/class1/server/ca/MEswSTBHMEUwQzAJBgUrDgMCGgUABAR571c85Prvkggz7EWCVSbdzaAjFQQUFbqcWolwWaxKVTlvLQA1YeCBz7MCChnePRMAAAAArhA%3D

But using curl and writing into a file might be more useful.

Wie wird die Gültigkeit von X.509v3 Zertifikaten überprüft?

Written by  on Oktober 26, 2015

Es gibt zumindest 3 Stellen, an denen Infos zu finden sind, ob ein X.509v3 Zertifikat noch gültig ist.
Verwirrend ist eigentlich nur, dass unter Windows alle Begriffe zwanghaft eingedeutscht wurden.

  • CDP (CRL Distribution Point), auf deutsch „Sperrlisten-Verteilunspunkt“
  • Wird die CRL vom CDP heruntergeladen gibt es unter „Freshest CRL“, auf deutsch „Aktuellste Sperrliste“ einen Eintrag für die Delta CRL, d.h. falls es eine gibt
  • AIA (Authority Information Access) auf deutsch „Zugriff auf Stelleninformation“ enthält den Pfad zum OCSP (Online Certificate Status Protocol) Responder