check x509 Certificate validity

I would like to check validity of a certificate x509 in flutter like this js method.

import tls from 'tls';
import { X509Certificate } from 'crypto'

function validCertificate(cert, key) {
  try {
    tls.createSecureContext({ cert, key })
    const { validTo } = new X509Certificate(cert);
    return new Date(validTo) > new Date()
  }
  catch (error) {
    if (error.code === 'ERR_OSSL_X509_KEY_VALUES_MISMATCH') {
      return false;
    }
    throw error;
  }
}


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation