test: certify device with id 1
This commit is contained in:
parent
968e9491cf
commit
69b0a619e0
1 changed files with 20 additions and 7 deletions
|
@ -13,7 +13,7 @@ from passlib import pwd
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from .config import CertificateAlgo, Config, Settings
|
from .config import CertificateAlgo, Config, Settings
|
||||||
from .db import Device
|
from .db import Connection, Device
|
||||||
|
|
||||||
|
|
||||||
class DistinguishedName(BaseModel):
|
class DistinguishedName(BaseModel):
|
||||||
|
@ -252,12 +252,25 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
ca = easy_rsa.build_ca()
|
ca = easy_rsa.build_ca()
|
||||||
server = easy_rsa.issue("server")
|
server = easy_rsa.issue("server")
|
||||||
# client = easy_rsa.issue(cert_type="client", cn="kiwi-vpn-client")
|
client = None
|
||||||
|
|
||||||
|
# check if configured
|
||||||
|
if (current_config := Config._) is not None:
|
||||||
|
# connect to database
|
||||||
|
Connection.connect(current_config.db.uri)
|
||||||
|
|
||||||
|
if (device := Device.get(1)) is not None:
|
||||||
|
with Connection.session as db:
|
||||||
|
db.add(device)
|
||||||
|
dn = DistinguishedName.build(device)
|
||||||
|
|
||||||
|
client = easy_rsa.issue("client", dn)
|
||||||
|
|
||||||
date_format, encoding = "%Y%m%d%H%M%SZ", "ascii"
|
date_format, encoding = "%Y%m%d%H%M%SZ", "ascii"
|
||||||
|
|
||||||
for cert in (ca, server):
|
for cert in (ca, server, client):
|
||||||
print(cert.get_subject().CN)
|
if cert is not None:
|
||||||
print(cert.get_signature_algorithm().decode(encoding))
|
print(cert.get_subject().CN)
|
||||||
print(datetime.strptime(
|
print(cert.get_signature_algorithm().decode(encoding))
|
||||||
cert.get_notAfter().decode(encoding), date_format))
|
print(datetime.strptime(
|
||||||
|
cert.get_notAfter().decode(encoding), date_format))
|
||||||
|
|
Loading…
Reference in a new issue