| 153 | }}} |
| 154 | |
| 155 | The {{{write_cert}}} and {{{write_cert_name}}} methods write the X.509 certificate from an identity. The private keys can similarly be read or written using {{{read_privkey_name}}} and {{{read_privkey}}}. The following snippet creates an identity, writes it to 2 files and reads it from those files printing the results. The output files will not contain the private key. |
| 156 | |
| 157 | {{{ |
| 158 | |
| 159 | import ABAC |
| 160 | |
| 161 | id = ABAC.ID("newGuy", 5*365*3600*24) |
| 162 | |
| 163 | id.write_cert_name("./newGuy.pem") |
| 164 | |
| 165 | id1 = ABAC.ID("./newGuy.pem") |
| 166 | |
| 167 | try: |
| 168 | f = open("./newGuy.pem") |
| 169 | id2 = ABAC.ID_chunk(f.read()) |
| 170 | f.close() |
| 171 | except: |
| 172 | pass |
| 173 | |
| 174 | print "%s %s %s" % (id.keyid(), id1.keyid(), id2.keyid()) |