def _newTLSContext(self, now=None): """Create and return a TLS context.""" if now is None: now = time.time() mmtpKey = mixminion.Crypto.pk_generate(MMTP_KEY_BYTES * 8) certStarts = now - CERTIFICATE_EXPIRY_SLOPPINESS expires = now + CERTIFICATE_LIFETIME certEnds = now + CERTIFICATE_LIFETIME + CERTIFICATE_EXPIRY_SLOPPINESS tmpName = self.certFile + "_tmp" generateCertChain(tmpName, mmtpKey, self.getIdentityKey(), self.nickname, certStarts, certEnds) replaceFile(tmpName, self.certFile) self._tlsContext = (mixminion._minionlib.TLSContext_new( self.certFile, mmtpKey, self._getDHFile())) self._tlsContextExpires = expires return self._tlsContext
def _newTLSContext(self, now=None): """Create and return a TLS context.""" if now is None: now = time.time() mmtpKey = mixminion.Crypto.pk_generate(MMTP_KEY_BYTES*8) certStarts = now - CERTIFICATE_EXPIRY_SLOPPINESS expires = now + CERTIFICATE_LIFETIME certEnds = now + CERTIFICATE_LIFETIME + CERTIFICATE_EXPIRY_SLOPPINESS tmpName = self.certFile + "_tmp" generateCertChain(tmpName, mmtpKey, self.getIdentityKey(), self.nickname, certStarts, certEnds) replaceFile(tmpName, self.certFile) self._tlsContext = ( mixminion._minionlib.TLSContext_new(self.certFile, mmtpKey, self._getDHFile())) self._tlsContextExpires = expires return self._tlsContext
def _changeState(self, handle, s1, s2): """Helper method: changes the state of message 'handle' from 's1' to 's2', and changes the internal count.""" try: self._lock.acquire() try: replaceFile(os.path.join(self.dir, s1+"_"+handle), os.path.join(self.dir, s2+"_"+handle)) except OSError, e: contents = os.listdir(self.dir) LOG.error("Error while trying to change %s from %s to %s: %s", handle, s1, s2, e) LOG.error("Directory %s contains: %s", self.dir, contents) self.count(1) return if self.n_entries < 0: return if s1 == 'msg' and s2 != 'msg': self.n_entries -= 1 elif s1 != 'msg' and s2 == 'msg': self.n_entries += 1
def _changeState(self, handle, s1, s2): """Helper method: changes the state of message 'handle' from 's1' to 's2', and changes the internal count.""" try: self._lock.acquire() try: replaceFile(os.path.join(self.dir, s1 + "_" + handle), os.path.join(self.dir, s2 + "_" + handle)) except OSError, e: contents = os.listdir(self.dir) LOG.error("Error while trying to change %s from %s to %s: %s", handle, s1, s2, e) LOG.error("Directory %s contains: %s", self.dir, contents) self.count(1) return if self.n_entries < 0: return if s1 == 'msg' and s2 != 'msg': self.n_entries -= 1 elif s1 != 'msg' and s2 == 'msg': self.n_entries += 1