Class for handling the CertificateStatus OCSP staples from RFC 4366.
| 173 | |
| 174 | |
| 175 | class CertificateStatus(messages.HandshakeMsg): |
| 176 | """Class for handling the CertificateStatus OCSP staples from RFC 4366.""" |
| 177 | |
| 178 | def __init__(self): |
| 179 | """Create a certificate status message handling object.""" |
| 180 | super(CertificateStatus, self).__init__( |
| 181 | HandshakeType.certificate_status) |
| 182 | self.status_type = 0 |
| 183 | self.response = None |
| 184 | |
| 185 | def parse(self, parser): |
| 186 | """Deserialise certificate status message from binary data.""" |
| 187 | parser.startLengthCheck(3) |
| 188 | self.status_type = parser.get(1) |
| 189 | if self.status_type == 1: # FIXME, create registry |
| 190 | self.response = parser.getVarBytes(3) |
| 191 | else: |
| 192 | raise SyntaxError() # FIXME, use sane-er type |
| 193 | parser.stopLengthCheck() |
| 194 | return self |
| 195 | |
| 196 | def __format__(self, formatstr): |
| 197 | """Return human-readable representation of certificate status.""" |
| 198 | response = format_bytearray(self.response, formatstr) |
| 199 | return "CertificateStatus(status_type={0}, response={1})"\ |
| 200 | .format(self.status_type, response) |
| 201 | |
| 202 | |
| 203 | class Message(messages.Message): |