Skip to content

Instantly share code, notes, and snippets.

View sanishchahero's full-sized avatar
🎯
Focusing

Sanish Maharjan sanishchahero

🎯
Focusing
  • eSewa Fonepay Pvt. Ltd.
  • Kirtipur, Kathmandu
View GitHub Profile
@sanishchahero
sanishchahero / SelfSignedCrtCertificate.java
Created July 10, 2020 08:56 — forked from erickok/SelfSignedCrtCertificate.java
Loading a self-signed SSL certificate .crt file and packaging it into a SSLSocketFactory for use with a HttpsURLConnection.
// Usage example...
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://someurl.com").openConnection();
connection.setSSLSocketFactory(buildSslSocketFactory());
private static SSLSocketFactory buildSslSocketFactory(Context context) {
// Add support for self-signed (local) SSL certificates
// Based on http://developer.android.com/training/articles/security-ssl.html#UnknownCa
try {
@sanishchahero
sanishchahero / ParseRSAKeys.java
Created May 2, 2020 14:03 — forked from destan/ParseRSAKeys.java
Parse RSA public and private key pair from string in Java
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
@sanishchahero
sanishchahero / bucket-policies-primer.md
Created April 30, 2019 11:27 — forked from krishnasrinivas/bucket-policies-primer.md
Explanation of bucket polices by example

Bucket Policy

Bucket policy is an access policy available for you to grant anonymous permissions to your Minio resources. Bucket policy uses JSON-based access policy language.

This section presents a few examples of typical use cases for bucket policies. The policies use testbucket strings in the resource value. To test these policies, you need to replace these strings with your bucket name. For more information please read Amazon S3 access policy language

Granting Read-Only Permission to an Anonymous User

The following example policy grants the s3:GetObject permission to any public anonymous users. This permission allows anyone to read the object data under testbucket, which is useful for when you have publicly readable assets. A typical example is a website assets stored in testbucket.