Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help to investigate how to create MTPROTO keys from usage example #18

Closed
rglitchard opened this issue Oct 10, 2020 · 3 comments
Closed
Labels
question questions about how to use this package

Comments

@rglitchard
Copy link

rglitchard commented Oct 10, 2020

Hello, @ololosha228. Thanks a lot for this library, can you please clarify how I can generate mtproto keys from your example?

func main() {
	keyfile := "/home/r0ck3t/go/src/github.com/xelaj/mtproto/keys/keys.pem"
	TelegramPublicKeys, err := keys.ReadFromFile(keyfile)
	dry.PanicIfErr(err)

I can't figure out how to generate this? Should I use the guide on the official documentation link: https://core.telegram.org/mtproto/auth_key or is there another way to do this? thanks

@quenbyako
Copy link
Member

Hey @rglitchard, thanks for creating issue!

You can get RSA keys from here. Just save all public keys of your app into single file, and add path in configs.

To be honest, you need just first RSA public key, i don't know yet, what the purpose of other keys. but i think they are need to make requests to telegram CDNs or something like this. Just save ALL keys, we'll update this lib when we understand, why do we need other public keys)

@quenbyako quenbyako pinned this issue Oct 10, 2020
@rglitchard
Copy link
Author

rglitchard commented Oct 10, 2020

Also, I suppose to add ENV files to the project. For example, if I changed the PATH into .pem keys, they otherwise already hardcoded in init() function on the telegram/common.go:

func init() {
	keyfile := "~/go/src/github.com/xelaj/mtproto/keys/keys.pem" // HERE IS CHANGE TO os.Getenv("MTPROTO_KEYS_PATH")
	TelegramPublicKeys, err := keys.ReadFromFile(keyfile)
	dry.PanicIfErr(err)
	choosedKey := dry.RandomChoose(dry.InterfaceSlice(TelegramPublicKeys)...).(*rsa.PublicKey)

	_ = choosedKey
}

If you agree with my idea, I can make the PR

@quenbyako
Copy link
Member

@rglitchard oh crap, i supposed that i fixed it already)))

enviroments are bad in vendor libs, but idea is good. Also, check out this branch, i'll soon merge it into master, it has multiple fixes of client, and has NewClient constructor, you can add path in params

@quenbyako quenbyako unpinned this issue Nov 4, 2020
@quenbyako quenbyako pinned this issue Nov 4, 2020
@quenbyako quenbyako added the question questions about how to use this package label Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question questions about how to use this package
Projects
None yet
Development

No branches or pull requests

2 participants