diff options
-rw-r--r-- | database.go | 5 | ||||
-rw-r--r-- | static/index.html | 4 | ||||
-rw-r--r-- | verification.go | 6 |
3 files changed, 9 insertions, 6 deletions
diff --git a/database.go b/database.go index edab4f6..954ec0f 100644 --- a/database.go +++ b/database.go @@ -31,7 +31,7 @@ func GetActorFromDB(db *sql.DB, id string) Actor { } nActor.PublicKey = GetActorPemFromDB(db, publicKeyPem) - if nActor.PublicKey.PublicKeyPem == ""{ + if nActor.Id != "" && nActor.PublicKey.PublicKeyPem == ""{ err = CreatePublicKeyFromPrivate(db, &nActor, publicKeyPem) CheckError(err, "error creating public key from private") } @@ -57,8 +57,7 @@ func GetActorByNameFromDB(db *sql.DB, name string) Actor { CheckError(err, "error with actor from db scan ") } - nActor.PublicKey = GetActorPemFromDB(db, publicKeyPem) - if nActor.PublicKey.PublicKeyPem == ""{ + if nActor.Id != "" && nActor.PublicKey.PublicKeyPem == ""{ err = CreatePublicKeyFromPrivate(db, &nActor, publicKeyPem) CheckError(err, "error creating public key from private") } diff --git a/static/index.html b/static/index.html index 520829e..bd90059 100644 --- a/static/index.html +++ b/static/index.html @@ -21,7 +21,8 @@ <div style="text-align: center; max-width: 800px; margin: 0 auto;"> <h1>{{ .Title }}</h1> <p style="text-align: justify">{{ .PreferredUsername }} is a federated image board based on activitypub. The current version of the code running the server is still a work in progress, expect a bumpy ride for the time being. Get the server code at <a href="https://github.com/FChannel0">https://github.com/FChannel0</a>.</p> - + + {{ if .Boards }} <div style="margin-top:50px;"> <div style="display: grid;border-right: 2px solid #820404"> <div style="display: inline-grid;grid-column: 1 / 4;border-bottom: 2px solid #820404;border-left: 2px solid #820404;border-top: 2px solid #820404;"><span style="font-size: 1.5em;font-weight: bold;">Local boards</span></div> @@ -33,6 +34,7 @@ {{ end }} </div> </div> + {{ end }} {{ if .NewsItems }} <div class="popup-box" style="margin-top:50px;"> diff --git a/verification.go b/verification.go index 1e9c50e..555e9ee 100644 --- a/verification.go +++ b/verification.go @@ -551,6 +551,7 @@ func CreatePublicKeyFromPrivate(db *sql.DB, actor *Actor, publicKeyPem string) e if block == nil || block.Type != "RSA PRIVATE KEY" { return errors.New("failed to decode PEM block containing public key") } + key, err := x509.ParsePKCS1PrivateKey(block.Bytes) CheckError(err, "failed to parse private key") @@ -561,13 +562,14 @@ func CreatePublicKeyFromPrivate(db *sql.DB, actor *Actor, publicKeyPem string) e Headers: nil, Bytes: publicKeyDer, } + publicFileWriter, err := os.Create(publicFilename) CheckError(err, "error creating public pem file for " + actor.Name) err = pem.Encode(publicFileWriter, &pubKeyBlock) CheckError(err, "error encoding public pem") }else{ - fmt.Println(`Unable to locate private key from public key generation. Now, + fmt.Println(`\nUnable to locate private key from public key generation. Now, this means that you are now missing the proof that you are the owner of the "` + actor.Name + `" board. If you are the developer, then your job is just as easy as generating a new keypair, but @@ -633,7 +635,7 @@ func ActivitySign(db *sql.DB, actor Actor, signature string) (string, error) { return base64.StdEncoding.EncodeToString(cipher), nil }else{ - fmt.Println(`Unable to locate private key. Now, + fmt.Println(`\n Unable to locate private key. Now, this means that you are now missing the proof that you are the owner of the "` + actor.Name + `" board. If you are the developer, then your job is just as easy as generating a new keypair, but |