<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Necatican Yıldırım on Medium]]></title>
        <description><![CDATA[Stories by Necatican Yıldırım on Medium]]></description>
        <link>https://medium.com/@necatican?source=rss-544637f9f209------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aHIFCYPcG_DpkogffS-geg.jpeg</url>
            <title>Stories by Necatican Yıldırım on Medium</title>
            <link>https://medium.com/@necatican?source=rss-544637f9f209------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 17:21:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@necatican/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Istio mTLS between multiple clusters]]></title>
            <link>https://medium.com/trendyol-tech/istio-mtls-between-multiple-clusters-b146829e40aa?source=rss-544637f9f209------2</link>
            <guid isPermaLink="false">https://medium.com/p/b146829e40aa</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[service-mesh]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[platform]]></category>
            <category><![CDATA[istio]]></category>
            <dc:creator><![CDATA[Necatican Yıldırım]]></dc:creator>
            <pubDate>Mon, 19 Apr 2021 08:08:18 GMT</pubDate>
            <atom:updated>2021-04-19T14:02:53.639Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*k4WjUgl6m3UbDfuqfYu8Cg.png" /><figcaption><a href="https://youtu.be/rir5yypoRU8?t=5067">Trendyol Women in Tech 2021 (Turkish)</a></figcaption></figure><p>In Trendyol we believe in autonomous teams, and try to provide any resources they need to fulfill the team’s needs. However, we also have some standardized tools to ensure the security and the quality of the services we provide. Istio is one of those. Istio is a powerful tool, that allows us to manage traffic, secure our services, get valuable telemetry. While it is possible to deploy Istio across multiple clusters, it would be both tedious and limiting for us to do so. We still need our meshes to communicate, in this article, I will explain how we deployed a multi-cluster/multi-mesh solution while leveraging the benefits of Istio.</p><p>While I expect you to know some about Istio, here’s a short recap on how Istio works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*rGKua4Vjgrvu4YPzX-VcwA.png" /><figcaption><a href="https://istio.io/latest/docs/ops/deployment/architecture/">Istio Architecture</a></figcaption></figure><p>Istio injects an envoy sidecar to every pod and makes sure all the traffic goes through the envoy proxy. Envoy proxies compose the data plane. The control plane manages the Envoy sidecars. In previous versions of Istio, the control plane used to have other components, such as Pilot, Citadel, and Galley. These components got consolidated into a single binary called “istiod”. The control plane also deals with the configurations, certificates, secrets, and health checking.</p><blockquote>If you want to read more about the istiod consolidation, you can check this <a href="https://istio.io/latest/blog/2020/istiod/">blog post</a> on istio.io.</blockquote><p>We want to be able to communicate with TLS through multiple clusters while tracing and managing each request. This is simple if we were to use a multi-cluster Istio installation. For our use case, we’ve found out two suitable solutions, using mTLS between the two clusters or using mTLS in each cluster and a secure gateway for inter-cluster communication.</p><p><strong>mTLS connection between clusters</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fPzK2PPVWnZGzEJn6BCTHQ.png" /><figcaption>Drawn with <a href="https://excalidraw.com/">Excalidraw</a></figcaption></figure><p>With a regular TLS connection, the client can verify the identity of the target. Sometimes this is not enough, with mutual TLS the server can verify the identity of the client too. This is a sought-after feature, especially when building secure micro-services.</p><p>To achieve mTLS between clusters, we will need to use our certificates. You will need a Root CA, intermediate certificate(s) generated by your Root CA. You also can generate some client certificates from your intermediate certificate. It is possible to use the same intermediate certificate for all the clusters or generate a new one for each as long as they belong to the same Root CA.</p><p>Follow the steps below to install Istio and configure it with your certificates on all clusters you will be working with. If you already have Istio installed, you can <a href="#b91e">rotate the root certificate</a>.</p><p><strong>Installing Istio from scratch</strong></p><p>We need to create a namespace for Istio, the default namespace is “istio-system”</p><pre>kubectl create namespace istio-system</pre><p>Then we create a secret with our certificates. It is okay to use the intermediate certificate for the cert-chain, <strong>Istio does not check the chain and validates identity by using SPIFFE IDs</strong>.</p><pre>kubectl create secret generic cacerts -n istio-system \</pre><pre>--from-file=ca-cert.pem=./intermediate.crt \</pre><pre>--from-file=ca-key.pem=./intermediate.key  \</pre><pre>--from-file=root-cert.pem=./root.crt       \</pre><pre>--from-file=cert-chain.pem=./intermediate.crt</pre><p>We can now follow the official docs to <a href="https://istio.io/latest/docs/setup/getting-started/">install Istio</a> before moving forward. Istio will configure itself to use the certificates we have given.</p><h4><strong>Deploying your app</strong></h4><p>We now need to prepare the namespace we are working on. We start by creating a namespace and enabling auto-injection for Istio by labeling it.</p><pre>kubectl create namespace mtls-facts<br>kubectl label namespace mtls-facts istio-injection=enabled</pre><p>Istio proxies use mTLS by default. Unless you’ve changed your configuration, you don’t need to worry about configuring mTLS. The default installation is configured for the <a href="https://istio.io/latest/docs/concepts/security/#permissive-mode">PERMISSIVE mode</a>.</p><p>We are now ready to deploy our app. I have created a simple Go app for demonstration purposes. We will be deploying this app on a single cluster, and access it from another cluster through an mTLS connection.</p><pre>kubectl apply -n mtls-facts -f https://gist.githubusercontent.com/necatican/70edfdd66f055f6c4b7cc0f40c23ee94/raw/6c151d4236c15e350fc836fe8cf1849d05061dfa/mtls-facts.yml</pre><p>We now need to create a secure gateway for the incoming requests. The host fields on the Gateway and the VirtualService are set to “*”. Caveat emptor.</p><pre>kubectl apply -n mtls-facts -f <a href="https://gist.githubusercontent.com/necatican/20102dc3351d30758e04cb4d8aacc207/raw/371950fb1aaf956fed8296e18abd4870c9928921/facts-gw-vs.yml">https://gist.githubusercontent.com/necatican/20102dc3351d30758e04cb4d8aacc207/raw/371950fb1aaf956fed8296e18abd4870c9928921/facts-gw-vs.yml</a></pre><p>We are now ready to access this service from the other clusters. We just need to find out the HTTPS port of our secure gateway, and the IP address of our cluster. I will be extracting the IP from my kubeconfig file.</p><pre>export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath=&#39;{.spec.ports[?(@.name==&quot;https&quot;)].nodePort}&#39;)</pre><pre>export KUBECONFIG_NODE_IP=$(kubectl config view -o jsonpath=&#39;{.clusters[].cluster.server}&#39; | grep -Eo &quot;([0-9]{1,3}[\.]){3}[0-9]{1,3}&quot;)</pre><pre>echo &quot;$KUBECONFIG_NODE_IP:$SECURE_INGRESS_PORT&quot;</pre><p>We are now ready to switch context, either by using <a href="https://github.com/ahmetb/kubectx">kubectx</a> or the good old export KUBECONFIG=$CONF_PATH . You may also just switch to a different terminal window, don’t forget to carry over the variables we’ve just exported</p><p>The following command will create the external namespace, a destination rule so Istio will try to create an mTLS connection and a Kubernetes service with an endpoint. Make sure to set KUBECONFIG_NODE_IP and SECURE_INGRESS_PORT variables before running it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b77e5d85758a465af208f1e1ca5f57c/href">https://medium.com/media/1b77e5d85758a465af208f1e1ca5f57c/href</a></iframe><p>We are all set now. We need to send a request from a pod, if you don’t have a pod available you can use the following command to create one. The pod has to be in the Istio mesh.</p><pre>kubectl apply -n mtls-facts-external -f - &lt;&lt;EOF<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: curl<br>  labels:<br>    app: curl<br>spec:<br>  containers:<br>  - name: curl<br>    image: curlimages/curl<br>    command: [&quot;/bin/sleep&quot;, &quot;3650d&quot;]<br>    imagePullPolicy: IfNotPresent<br>  restartPolicy: Always<br>EOF</pre><p>And the final command to test the connection.</p><pre>kubectl exec -ti curl -c curl -n mtls-facts-external -- curl facts-service.mtls-facts-external/fact</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADz7zoQ0pj5zS0uIXVG_5g.gif" /><figcaption>Make sure to send a request from a pod with an Envoy Proxy.</figcaption></figure><h4><strong>Changing root and intermediate certificates when Istio is already installed.</strong></h4><p>If you already have Istio installed, you will either have cacerts (user certificates) or istio-ca-secret (certificates self-signed by Istio) secrets in the istio-system namespace. We start by deleting these secrets to replace them with our own.</p><pre>kubectl delete secret -n istio-system cacerts<br>kubectl delete secret -n istio-system istio-ca-secret</pre><p>Then we can follow the steps for the scratch installation with one exception. Instead of installing Istio, we need to restart istiod and istio-ingressgateway pods. For our Istio configuration at Trendyol, the following commands will suffice.</p><pre>kubectl rollout restart deployment -n istio-system istiod</pre><pre>kubectl rollout restart daemonset -n istio-system istio-ingressgateway</pre><blockquote>Your IngressGateway rollout might get stuck. This happens because the istiod service was not able to update the certificates. You can wait for a while and try again or check the value of the <em>istio-ca-root-cert</em> ConfigMap before rolling out the IngressGateway pods. To check the value of the current root certificate you can use the following command. <em>kubectl get cm -n istio-system istio-ca-root-cert -o jsonpath=’{.data.root-cert\.pem}’</em></blockquote><p>Depending on your configuration, your gateway pods might come from a deployment or a daemonset. If you can not be sure, you can delete all the pods in the istio-system namespace.</p><pre>kubectl delete pod --all -n istio-system</pre><p>Once all your pods start running, you can proceed to the next step.</p><h3><strong>Few questions you might have</strong></h3><ol><li><strong>The connection between the Envoy Proxy and your container is not encrypted.</strong></li></ol><p>The TLS origination and termination happens in the Envoy proxy. It is possible to intercept and read this plain connection with tools such as <a href="https://github.com/eldadru/ksniff">ksniff</a>. It is possible to prevent this by using <a href="https://github.com/open-policy-agent/gatekeeper">OPA Gatekeeper</a>. Luckily, Trendyol has a lot of brilliant minds, and some of them already did the hard work for us. You can read the following article for a nice headstart.</p><p><a href="https://medium.com/trendyol-tech/enforce-organizational-policies-and-security-best-practices-to-your-kubernetes-clusters-by-using-dfc085528e07">Enforce Organizational Policies and Security Best Practices to your Kubernetes Clusters By Using…</a></p><p><strong>2. Ingress gateway rollouts can fail</strong></p><p>If rollout starts before istiod processes the new certificate, your IngressGateway rollout might get stuck. You do not want this behavior in a pipeline. Here is a little bash snippet I have used to overcome this problem.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2dd5aca60af679f28188647fa6e6c85b/href">https://medium.com/media/2dd5aca60af679f28188647fa6e6c85b/href</a></iframe><p><strong>3. We access the endpoint using HTTP</strong></p><p>We access the facts-service.mtls-facts-external using the HTTP port. This may sound alarming but it is not a problem. The DestinationRule will force an mTLS connection. Our Endpoint points to the HTTPS port of the serving cluster’s IngressGateway.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b146829e40aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trendyol-tech/istio-mtls-between-multiple-clusters-b146829e40aa">Istio mTLS between multiple clusters</a> was originally published in <a href="https://medium.com/trendyol-tech">Trendyol Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of encryption and hashing]]></title>
            <link>https://necatican.medium.com/basics-of-encryption-and-hashing-b9d925672c46?source=rss-544637f9f209------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9d925672c46</guid>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Necatican Yıldırım]]></dc:creator>
            <pubDate>Sun, 21 Jun 2020 18:53:56 GMT</pubDate>
            <atom:updated>2020-06-24T19:41:51.718Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn about encryption, hashing, and key exchange.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0WyZtJDbcAKO0r53" /><figcaption>Photo by <a href="https://unsplash.com/@mattartz?utm_source=medium&amp;utm_medium=referral">Matt Artz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Secrecy and privacy are crucial for people. Throughout history, humankind has been interested in conveying messages in a way that other people won’t be able to understand. People use different languages, slang words, nonverbal cues to get their messages across without other people knowing. While these offer privacy to some degree, they are not suited for confidential data. Whether it’s an army trying to protect their secret plans, or children trying to make a joke that their teacher will not be able to understand, they might feel the need to use some sort of encryption.</p><p>In the age of computers and the internet, cryptography is way more important than ever. So much so that it is almost impossible to avoid cryptography. From your cellphones to your smart fridges and even when you are reading this article you are using an encrypted connection. Encryption even enables us to make our payments using digital currencies. So how does it work?</p><p>It is possible to encrypt data in two ways:</p><ol><li>Encrypting and decrypting using the same secret key. (Symmetric)</li><li>Encrypting with a key and decrypting with a different key. (Asymmetric)</li></ol><p>Before we move onto encryption, I would like to write about hashing. While the purpose of encrypting and decrypting the data is rather obvious, there are other subtle ways that we can use cryptography for. Knowing the legitimacy of the data is one of them. It is possible to use encryption algorithms to verify data. This process is called hashing and it doesn’t store the data itself but the summary of it. Hashes are also fixed in size, allowing people to transfer them easily. Their size depends on the algorithm. For example, a SHA1 hash is 40 characters long.</p><p><a href="https://en.wikipedia.org/wiki/Collision_(computer_science)">Collisions</a> are possible in some algorithms like <a href="https://en.wikipedia.org/wiki/MD5#Collision_vulnerabilities">md5</a>. Collisions are highly problematic since they can lead to forgery. You should avoid using hashing algorithms with collisions.</p><p>Keep in mind, hashing is not encrypting. It is not possible to reverse a hash using an algorithm or a key. However, it is possible to try different combinations with the same algorithm until you get the same hash. This requires an insane amount of computation power for complex data and it’s usually referred to as “<a href="https://en.wikipedia.org/wiki/Brute-force_attack">Brute Forcing</a>”.</p><p>To combat with computation cost of brute-forcing, people started to pre-compute hashes for common passwords and numbers. These pre-computed tables are called “<a href="https://en.wikipedia.org/wiki/Rainbow_table">Rainbow Tables</a>”. Rainbow tables use storage instead of computation power as it is easier and cheaper to allocate disk space instead of increasing your processing power. You can even use a search engine to reverse some indexed hashes, try searching for “5f4dcc3b5aa765d61d8327deb882cf99”, it is an md5 hash of the word “password”.</p><p>Nowadays it is a common practice to add some random data while hashing. This process is called salting. Using this process prevents people from using tables and forces them to use computational power. It usually is not fancy, for example, if you wanted to salt “password”, you could just hash “GDzv7tF9fjcmWnpassword” instead. You should save the salt for each hash, so you could salt the user input and hash it again to compare. If you are going to hash passwords do not forget to take people’s passwords with a grain of salt.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FS9JGmA5_unY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DS9JGmA5_unY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FS9JGmA5_unY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f999e918426765d3aed0f734c468a5ee/href">https://medium.com/media/f999e918426765d3aed0f734c468a5ee/href</a></iframe><p>Now that I got hashing out of the way, I can write move onto symmetric and asymmetric encryption. These algorithms are designed to store data. The recipients in a conversation must be able to decrypt the messages they receive, otherwise, it’s garbled data. Decrypting data requires a key, anyone with the key can decrypt the data.</p><p><strong>- Symmetric Encryption</strong></p><p>Symmetric encryption is encryption with a single key. You can encrypt and decrypt the data with the same key. This is good for one-on-one conversations. Popular messaging apps such as <a href="https://www.whatsapp.com/security/WhatsApp-Security-Whitepaper.pdf">WhatsApp, rely on this method</a>.</p><p>For group chats, data for each member is encrypted, treating each member as a one-on-one chat with the sender. This is important because more people using the same key means a higher chance of a leak.</p><p><strong>- Asymmetric Encryption</strong></p><p>A chain is only as strong as its weakest link. Asymmetric encryption allows people to send data without having the decryption key. Everything encrypted with the public key can be decrypted with the private key.</p><p>The most common asymmetric encryption algorithm is <a href="https://en.wikipedia.org/wiki/RSA_(cryptosystem)">RSA</a>. <a href="https://en.wikipedia.org/wiki/GNU_Privacy_Guard">GPG (GNU Privacy Guard)</a> is also used by many to secure personal communications.</p><p>Both public and private keys of RSA can be used for encrypting and decrypting. You can encrypt data with one of the keys and decrypt it with the other. The same key cannot be used to decrypt the data, which allows people to share their public key without security risks. People can add their GPG keys on their profile, and receive encrypted messages from other people.</p><p>Asymmetric encryption is also used for <strong>SSH Authentication</strong>.</p><p>Here’s how it works:</p><ol><li>If you want to use key-based authentication, you should have a list of authorized keys. The default location for this file is in `~/.ssh/authorized_keys`. In this file, there are public keys that are allowed to connect to the server. Public keys in this file are separated with line breaks.</li><li>When someone tries to connect to the server, they send their public key.</li><li>If the public key is in the authorized_keys file, the server encrypts a random data with the public key and sends it to the user.</li><li>The user decrypts the data with their private key and hashes the decrypted data, then sends the hash back.</li><li>The server compares the hash with the original data hash. If it is a match, the authentication process is successful.</li></ol><p>Every encryption algorithm requires a key exchange as long as there is a recipient. Handing the keys over in person would be secure, but it is not always viable. For example, <a href="https://www.nist.gov/pml/time-and-frequency-division/time-services/nist-authenticated-ntp-service">NIST only delivers keys by US mail or FAX</a>. As I mentioned earlier, even to read this post you must be able to decrypt the data, which means you must perform an exchange.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*uXHiYopXCehuH_6qzFUkgQ.png" /><figcaption><a href="https://commons.wikimedia.org/wiki/File:Diffie-Hellman_Key_Exchange.svg">Illustration of the idea of the Diffie-Hellman key exchange.</a></figcaption></figure><p>Without encryption, your data is not secure. Exchanging keys requires an unencrypted channel, yet other people listening should not be able to acquire the secret key. <a href="https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange"><strong>Diffie–Hellman key exchange</strong></a><strong> </strong>comes into play here. Using Diffie-Hellman it is possible to share secret keys using an insecure channel.</p><p>Here’s how it works:</p><ol><li>Two participants (Alice and Bob) agree to use a public key (Key B). Any eavesdropper can see this key.</li><li>They both create their own private key. Alice creates Key A and Bob creates key B.</li><li>They combine their private key with the public key (Key P) and then sends it over. Alice sends AP, while Bob sends BP.</li><li>Each participant combines the key they have received with their own private key. This results in each participant having the same key, a combination of A, P, and B. The eavesdroppers can only see AP, BP, and P, so they cannot create APB.</li></ol><p><a href="https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">Diffie-Hellman Wikipedia page</a> has a mathematical explanation.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNmM9HA2MQGI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNmM9HA2MQGI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNmM9HA2MQGI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ecac01b763c99ec1f74e3ca4dd4a5646/href">https://medium.com/media/ecac01b763c99ec1f74e3ca4dd4a5646/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9d925672c46" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>